home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / dtp / textread / source / textread_1.13.s < prev    next >
Encoding:
Text File  |  1996-07-16  |  173.3 KB  |  10,659 lines

  1. ;TOSAAABIAKOAAAAAAAAAAABNLGCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPPPMKDPA
  2. *** ScR ***
  3.  
  4. final    =1
  5. setnamelen        =256
  6. release            =113
  7. releasestr    MACRO
  8.         dc.b    "1.13"
  9.         ENDM
  10. version            =38
  11. revision        =82
  12. date        MACRO
  13.         dc.b    "3.8.95"
  14.         ENDM
  15.     
  16. versionstr    MACRO
  17.         dc.b    version/10+'0',(version-version/10*10)+'0'
  18.         ENDM
  19. revisionstr    MACRO
  20.         dc.b    revision/10+'0',(revision-revision/10*10)+'0'
  21.         ENDM
  22.  
  23. ;TIPS: Ha en flagga för varje buffert, en för ladda, en för countlines.
  24. ;      multi_loadrest kan då heta multi_update, och går igenom alla buffertar
  25. ;      och kollar om dom ska ladda in en fil, eller räkna om raderna. (nja..)
  26.  
  27.  
  28.     ifeq    final-1
  29.     PRINTT    "Final version...  :-)"
  30.     auto    wo sys:cp
  31.     endif
  32.  
  33.     incdir    Asminclude:
  34.     include    devices/printer.i
  35.     include    devices/prtbase.i
  36.     include    dos/datetime.i
  37.     include    dos/dos.i
  38.     include    dos/dos_lib.i
  39.     include    dos/dosextens.i
  40.     include    dos/dostags.i
  41.     include    exec/alerts.i
  42.     include    exec/exec.i
  43.     include    exec/exec_lib.i
  44.     include    graphics/rastport.i
  45.     include    graphics/graphics_lib.i
  46.     include    graphics/gfxbase.i
  47.     include    graphics/displayinfo.i
  48.     include    intuition/gadgetclass.i
  49.     include    intuition/preferences.i
  50.     include    intuition/intuition.i
  51.     include    intuition/intuition_lib.i
  52.     include    libraries/asl.i
  53.     include    libraries/asl_lib.i
  54.     include    libraries/diskfont_lib.i
  55.     include    libraries/gadtools.i
  56.     include    libraries/gadtools_lib.i
  57.     include    utility/utility.i
  58.     include    utility/utility_lib.i
  59.     include    utility/tagitem.i
  60.     include    workbench/workbench.i
  61.     include workbench/wb_lib.i
  62.     include workbench/icon_lib.i
  63.     include workbench/startup.i
  64.  
  65. NM_COMMANDSTRING        EQU     COMMSEQ
  66. GTMN_NewLookMenus    EQU    GT_TagBase+67
  67. GTLV_MakeVisible    EQU    GT_TagBase+78    ; Make this item visible
  68. WA_NewLookMenus        EQU    $80000093
  69. WA_BusyPointer        EQU    WA_MenuHelp+6
  70. SA_MinimizeISG        EQU    $80000049
  71. BMA_FLAGS        EQU    12
  72. BMF_STANDARD        EQU    8
  73.  
  74. _LVOSetWindowPointerA    EQU    -$330
  75. _LVOLoadRGB32        EQU    -882
  76. _LVOGetRGB32        EQU    -900
  77. _LVOGetUniqueID        EQU    -270
  78. _LVOGetBitMapAttr    EQU    -960
  79.  
  80.     include    libraries/ppbase.i
  81.     include    libraries/powerpacker_lib.i
  82.     include    libraries/xpk.i
  83.  
  84.     incdir    include:
  85.     include    hardware/custom.i
  86.     include    hardware/intbits.i
  87.     include    macros.i
  88.  
  89. Message    MACRO
  90.     base    intui
  91.     move.l    windowptr(pc),a0
  92.     move.l    #-1,a1
  93.     lea    \1,a2
  94.     call    SetWindowTitles
  95.     ENDM
  96. wm    macro
  97.     btst    #6,$bfe001
  98.     bne.s    *-8
  99.     btst    #6,$bfe001
  100.     beq.s    *-8
  101.     endm
  102. fl    macro
  103.     move.w    #$ffff,d0
  104.     move.w    d0,$dff180
  105.     dbf    d0,*-6
  106.     endm
  107.  
  108.  STRUCTURE cm,MN_SIZE
  109.    UWORD   cm_command
  110.    ULONG   cm_data
  111.    LABEL   cm_SIZE
  112.  
  113. cmc_open    =1    ;data: pek till lws: filnamn, setname, tabsize
  114. cmc_opennew    =2    ; -"-
  115. cmc_quit    =3    ;N/A
  116.  
  117. err_exitnow    =-1
  118. err_noscreen    =-2
  119. err_nowin    =-3
  120. err_nomenu    =-4
  121. err_nogadget    =-5
  122. err_nofontreq    =-6
  123. err_nofilereq    =-7
  124. err_nomem    =-8
  125. err_nochipmem    =-9
  126. err_nofont    =-10
  127.  
  128.  
  129. ;SHIFTMENU    macro
  130. ;    and.w    #$1F,\1
  131. ;    endm
  132. ;SHIFTITEM    macro
  133. ;    and.w    #$3F,\1
  134. ;    lsl.w    #5,\1
  135. ;    emdm
  136. ;SHIFTSUB    macro
  137. ;    and.w    #$1F,\1
  138. ;    lsl.w    #11,\1
  139. ;    emdm
  140.  
  141. s_exit        =0
  142. TAB        =9
  143.  
  144. start:
  145.         ifeq final-1
  146.     include    startup.i
  147.     move.l    a0,wbmessage
  148.     move.l    d0,boolcli
  149.         endif
  150.     jmp    realstart
  151.  
  152. stayalive:                ;Only exec may be used here!
  153.     base    exec
  154.  
  155.         ifeq final-1
  156.     lea    dosname,a1
  157.     moveq    #0,d0
  158.     call    OpenLibrary
  159.     move.l    d0,a6
  160.     lea    start-4(pc),a0
  161.     move.l    (a0),d1            ;Other segments
  162.     clr.l    (a0)            ;Detach
  163.     call    UnLoadSeg        ;Free
  164.     move.l    a6,a1
  165.     base    exec
  166.     call    CloseLibrary
  167.         endif
  168.  
  169.     move.l    comport(pc),a0
  170.     call    WaitPort
  171. .getallcommsgs
  172.     move.l    comport(pc),a0
  173.     call    GetMsg
  174.     tst.l    d0
  175.     beq.w    .lastmess
  176.     move.l    d0,a1
  177.     move.w    cm_command(a1),d2
  178.     call    ReplyMsg
  179.     cmp.w    #cmc_quit,d2
  180.     beq.b    terminate
  181.     bra.s    .getallcommsgs
  182. .lastmess
  183.  
  184. terminate:
  185.     base    exec
  186.     move.l    commessage(pc),d0
  187.     move.l    d0,a1
  188.     beq.b    .nocommessage
  189.     moveq    #cm_SIZE,d0
  190.     call    FreeMem
  191. .nocommessage
  192.     tst.w    comportispublic
  193.     beq.b    .comnotadded
  194.     move.l    comport(pc),d0
  195.     move.l    d0,a1
  196.     beq.b    .nocomport
  197.     call    RemPort
  198. .comnotadded
  199.     move.l    comport(pc),d0
  200.     move.l    d0,a0
  201.     beq.b    .nocomport
  202.     call    DeleteMsgPort
  203. .nocomport
  204.  
  205.     moveq    #0,d0
  206.     rts
  207.  
  208.  
  209. comport:    dc.l    0
  210. commessage:    dc.l    0
  211. comportispublic:dc.w    0
  212.  
  213.         RSRESET
  214. coma_version:    rs.l    1    ;cli/wb
  215. coma_setname:    rs.l    1    ;cli/wb
  216. coma_boolcli:    rs.l    1    ;cli/wb
  217. coma_tabsize:    rs.l    0    ;cli
  218. coma_numargs:    rs.l    1    ;wb
  219. coma_argnames:    rs.l    0    ;cli
  220. coma_arglist:    rs.l    1    ;wb
  221. coma_currdir:    rs.l    1    ;cli, LOCK!
  222. coma_SIZE:    rs.l    0
  223.  
  224.  
  225.     section    realcode,code
  226. realstart:
  227.     jsr    openlibs
  228.     tst.l    d0
  229.     bmi.w    exit_nolibs
  230.  
  231.     jsr    fixwinmenu        ;if not V39+, remove "Esc", "Tab" etc
  232.     jsr    multi_init
  233.     tst.l    d0
  234.     beq    exit
  235.  
  236.         ifeq final-1
  237.     jsr    getargs
  238.     tst.l    d0
  239.     bmi.w    exit_argerr
  240.         endif
  241.  
  242.     base    exec
  243.     call    CreateMsgPort
  244.     lea    comport,a0
  245.     move.l    d0,(a0)
  246.     beq.w    exit
  247.  
  248.     tst.l    argnew
  249.     bne.w    .startnewcopy
  250.  
  251.     base    exec
  252.     moveq    #cm_SIZE,d0
  253.     move.l    #MEMF_PUBLIC!MEMF_CLEAR,d1
  254.     call    AllocMem
  255.     lea    commessage,a0
  256.     move.l    d0,(a0)
  257.     beq.w    exit
  258.  
  259.     move.l    commessage,a1
  260.     move.l    comport,MN_REPLYPORT(a1)
  261.     move.w    #cm_SIZE,MN_LENGTH(a1)
  262.     move.w    #cmc_opennew,cm_command(a1)
  263.     lea    com_array,a0
  264.     move.l    a0,cm_data(a1)
  265.  
  266.     suba.l    a1,a1
  267.     call    FindTask
  268.     move.l    d0,a1
  269.  
  270.     lea    com_array,a0
  271.     move.l    #release,coma_version(a0)
  272.     move.l    pr_CurrentDir(a1),coma_currdir(a0)
  273.     move.l    argset(pc),coma_setname(a0)
  274.     move.l    boolcli(pc),coma_boolcli(a0)
  275.     bne.w    .cli
  276.     move.l    wbmessage(pc),a1
  277.     move.l    sm_NumArgs(a1),coma_numargs(a0)
  278.     move.l    sm_ArgList(a1),coma_arglist(a0)
  279.     bra.b    .messageinited
  280. .cli
  281.     move.l    tabsize(pc),coma_tabsize(a0)
  282.     move.l    argnames(pc),coma_argnames(a0)
  283. .messageinited
  284.     base    exec
  285.     call    Forbid
  286.     lea    programname(pc),a1
  287.     call    FindPort
  288.     tst.l    d0
  289.     beq.b    .noprevcomport
  290.  
  291.     move.l    d0,a0
  292.     move.l    commessage,a1
  293.     call    PutMsg
  294.     call    Permit
  295.  
  296.     move.l    comport,a0
  297.     call    WaitPort
  298. .getallcommsgs
  299.     move.l    comport,a0
  300.     call    GetMsg
  301.     tst.l    d0
  302.     bne.s    .getallcommsgs
  303.  
  304.     bsr.w    cleanup
  305.     jmp    stayalive
  306.  
  307. .noprevcomport
  308.     call    Permit
  309.  
  310. .startnewcopy
  311.     move.l    comport,a1
  312.     lea    programname(pc),a0
  313.     move.l    a0,LN_NAME(a1)
  314.     move.b    #1,LN_PRI(a1)
  315.     call    AddPort
  316.     move.w    #1,comportispublic
  317.  
  318.     lea    bufflist(pc),a0
  319.     TSTNODE    a0,a0
  320.     beq.w    exit
  321.     lea    thisbuff(pc),a1
  322.     move.l    a0,(a1)
  323.     bsr    multi_buff2curr
  324.  
  325.     lea    bufflist(pc),a5
  326.     IFEMPTY    a5,.listisempty
  327.     move.l    MLH_HEAD(a5),a5
  328.     bsr    multi_loadrest
  329.     tst.l    d0
  330.     bne.b    exit
  331. .listisempty
  332.  
  333. *** int server
  334.     base    exec
  335.     moveq    #-1,d0
  336.     call    AllocSignal
  337.     lea    intsignal(pc),a0
  338.     move.l    d0,(a0)
  339.     cmp.l    #-1,d0
  340.     beq.w    exit
  341.  
  342.     lea    int,a1
  343.     move.b    #NT_INTERRUPT,LN_TYPE(a1)
  344.     move.b    #5,LN_PRI(a1)
  345.     lea    intname(pc),a0
  346.     move.l    a0,LN_NAME(a1)
  347.     lea    intsignal(pc),a0
  348.     move.l    a0,IS_DATA(a1)
  349.     lea    interruptet(pc),a0
  350.     move.l    a0,IS_CODE(a1)
  351.     moveq    #INTB_VERTB,d0
  352.     call    AddIntServer
  353.  
  354.  
  355.     bsr.w    handlesignals
  356.     bsr    mopenwb
  357.  
  358. *******************************************************************************
  359.  
  360. exit:
  361.     bsr.b    cleanup
  362.     jmp    terminate
  363.  
  364. cleanup:
  365.     base    exec
  366.     move.l    intsignal(pc),d0
  367.     cmp.l    #-1,d0
  368.     beq.b    .nointsignal
  369.     call    FreeSignal
  370.     lea    int,a1
  371.     moveq    #INTB_VERTB,d0
  372.     call    RemIntServer
  373. .nointsignal
  374.  
  375.     bsr    multi_quit
  376.     bsr.w    closeenvironment
  377. exit_argerr:
  378.     base    dos
  379.     move.l    rastruct(pc),d1
  380.     beq.b    .noargs
  381.     call    FreeArgs
  382. .noargs
  383.     lea    pipeused(pc),a0
  384.     tst.b    (a0)
  385.     bne.b    .nopipe
  386.  
  387.     base    dos
  388.     lea    pipename(pc),a0
  389.     move.l    a0,d1
  390.     call    DeleteFile
  391. .nopipe
  392.  
  393. exit_nolibs:
  394.     bsr.w    closelibs
  395.     rts
  396.  
  397. *******************************************************************************
  398.  
  399. handlesignals:
  400.  
  401. ;*** slav!
  402. ;    base    dos
  403. ;    lea    .dostags(pc),a0
  404. ;    move.l    a0,d1
  405. ;    call    CreateNewProc
  406. ;    lea    slave(pc),a0
  407. ;    move.l    d0,(a0)
  408. ;    beq.w    .noslave
  409. .loop
  410.     base    exec
  411.     moveq    #0,d0
  412.     move.l    intsignal(pc),d1
  413.     bset    d1,d0
  414.     call    Wait            ;the intserver signals each vblank..
  415.  
  416.     move.l    windowptr(pc),a0
  417.     move.l    wd_UserPort(a0),a0
  418.     move.b    MP_SIGBIT(a0),d1
  419.     moveq    #0,d0
  420.     bset    d1,d0
  421.     lea    .usersignal(pc),a0
  422.     move.l    d0,(a0)
  423.  
  424.     move.l    comport,a0
  425.     move.b    MP_SIGBIT(a0),d1
  426.     moveq    #0,d0
  427.     bset    d1,d0
  428.     lea    .comsignal(pc),a0
  429.     move.l    d0,(a0)
  430.  
  431.     or.l    .usersignal(pc),d0
  432.     bset    #SIGBREAKB_CTRL_C,d0
  433.  
  434.     lea    .signal(pc),a0
  435.     move.l    d0,(a0)
  436.  
  437.     moveq    #0,d0
  438.     moveq    #0,d1
  439.     call    SetSignal
  440.     and.l    .signal(pc),d0
  441.     beq.s    .scrolla        ;no signals
  442.  
  443.     base    exec
  444.     lea    .signal(pc),a0
  445.     move.l    d0,(a0)
  446.     call    Wait            ;fetch and clear
  447.     lea    .signal(pc),a0
  448.     move.l    d0,(a0)
  449.  
  450.     move.l    .signal(pc),d1
  451.     and.l    .usersignal(pc),d1    ;userport signal?
  452.     beq.B    .nouserport
  453.     bsr.w    handleIDCMP        ;yep
  454.     tst.l    d0
  455.     bmi.b    .exit
  456. .nouserport
  457.     move.l    .signal(pc),d1
  458.     and.l    .comsignal(pc),d1    ;comport signal?
  459.     beq.B    .nocomport
  460.     bsr    handleCOM        ;yep
  461. .nocomport
  462.     move.l    .signal(pc),d1
  463.     and.l    #SIGBREAKF_CTRL_C,d1
  464.     beq.B    .nobreak
  465.     lea    status(pc),a0
  466.     bset    #s_exit,(a0)        ;if ctrl_c from cli, quit!
  467. .nobreak
  468. .scrolla
  469.     move.w    scrolla(pc),d0
  470.     beq.s    .noscroll
  471.     cmp.w    #scrolla_mouse,d0
  472.     bne.s    .dontupdatespeed
  473.     moveq    #0,d0
  474.     move.w    mousey(pc),d0
  475.     mulu.w    #9,d0
  476.     divu.w    pheight+2(pc),d0
  477.     subq.w    #4,d0
  478.     cmp.w    #4,d0
  479.     ble.s    .speedok
  480.     moveq    #4,d0
  481. .speedok
  482.     lea    scrollfart(pc),a0
  483.     move.w    d0,(a0)
  484.     bra.s    .scrollit
  485. .dontupdatespeed
  486.     cmp.w    #scrolla_crsr,d0
  487.     bne.s    .noscroll
  488.     clr.w    scrolla            ;key pressed, clear.
  489. .scrollit
  490.     move.w    scrollfart(pc),d0
  491.     bsr    scrollsmooth
  492. .noscroll
  493.  
  494.     lea    status(pc),a0
  495.     btst    #s_exit,(a0)
  496.     beq.w    .loop
  497.  
  498. .exit
  499.  
  500. ;    lea    slavecmd+slavemessage(pc),a0
  501. ;    move.w    #-1,(a0)        ;tala om att avsluta!
  502. ;    bsr    slavesendmsg
  503. ;.noslave
  504.     rts
  505.  
  506. .signal        dc.l    0
  507. .usersignal    dc.l    0
  508. .comsignal    dc.l    0
  509.  
  510. ;.dostags
  511. ;    dc.l    NP_Entry,slavefunc
  512. ;    dc.l    NP_Name,.slavename
  513. ;    dc.l    TAG_DONE
  514. ;.slavename
  515. ;    dc.b    "Textread slave process",0
  516.  
  517. scrolla_mouse:    equ    1
  518. scrolla_crsr:    equ    2
  519. scrolla:    dc.w    0
  520. scrollfart:    dc.w    0
  521. mousey:        dc.w    0
  522.  
  523. intsignal:    dc.l    -1
  524.  
  525. interruptet:
  526.     base    exec
  527.     move.l    (a1),d1
  528.     moveq    #0,d0
  529.     bset    d1,d0
  530.     move.l    thistask(pc),a1
  531.     call    Signal
  532.     moveq    #0,d0
  533.     rts
  534.  
  535. *******************************************************************************
  536. ********************** C O M  *************************************************
  537. *******************************************************************************
  538. handleCOM:
  539. .loop
  540.     base    exec
  541.     move.l    comport,a0
  542.     call    GetMsg
  543.     tst.l    d0
  544.     beq.w    .exit
  545.     move.l    d0,.mess
  546.     move.l    d0,a0
  547.     cmp.w    #cmc_opennew,cm_command(a0)
  548.     bne.b    .notopennew
  549.     pushm    a0
  550.     bsr    mnew
  551.     popm    a0
  552.     bra.b    .open
  553. .notopennew
  554.     cmp.w    #cmc_open,cm_command(a0)
  555.     bne.b    .notopen
  556. .open
  557.     lea    .array(pc),a1
  558.     move.l    cm_data(a0),(a1)
  559.  
  560.     lea    .thisbuff(pc),a0
  561.     move.l    thisbuff(pc),(a0)
  562.  
  563.     move.l    .array(pc),a0
  564.     cmp.l    #release,coma_version(a0)
  565.     bne.b    .notopen
  566.     move.l    coma_setname(a0),a0
  567.     bsr    loadsettings
  568.     bsr    prefs2curr
  569.     move.l    .array(pc),a0
  570.     tst.l    coma_boolcli(a0)
  571.     bne.b    .cli
  572.     move.l    coma_numargs(a0),d1
  573.     move.l    coma_arglist(a0),a2
  574.     bsr.w    parsewbarg
  575.     bra.b    .open_buffscreated
  576. .cli
  577.     lea    tabsize(pc),a1
  578.     move.l    coma_tabsize(a0),(a1)
  579.     move.l    coma_argnames(a0),a2
  580.     move.l    .array(pc),a0
  581.     move.l    coma_currdir(a0),d0
  582.     bsr.w    parsefilenamearray
  583. .open_buffscreated
  584.     move.l    .thisbuff(pc),a5
  585.     bsr    multi_loadrest
  586.     move.l    .mess(pc),a0
  587.     ;remeber who signalled us, send a quit message when the buffer
  588.     ;is closed later on (multi_freebuff)
  589.     move.l    MN_REPLYPORT(a0),buff_commessageport(a5)
  590. .notopen
  591.     base    exec
  592.     move.l    .mess(pc),a1
  593.     call    ReplyMsg
  594.     bra.w    .loop
  595. .exit
  596.     rts
  597. .mess        dc.l    0
  598. .array        dc.l    0
  599. .thisbuff    dc.l    0
  600.  
  601. *******************************************************************************
  602. ********************** I D C M P **********************************************
  603. *******************************************************************************
  604. handleIDCMP:
  605.     base    gt
  606.     move.l    windowptr(pc),a0
  607.     move.l    wd_UserPort(a0),a0
  608.     call    GT_GetIMsg
  609.     tst.l    d0
  610.     beq.w    .exit
  611.     moveq    #0,d3
  612.     moveq    #0,d4
  613.     moveq    #0,d5
  614.     moveq    #0,d6
  615.     move.l    d0,a0
  616.     move.l    im_IAddress(a0),a2
  617.     move.l    im_Class(a0),d2
  618.     move.w    im_Code(a0),d3
  619.     move.w    im_Qualifier(a0),d4
  620.     move.w    im_MouseX(a0),d5
  621.     move.w    im_MouseY(a0),d6
  622.         movem.l    a0/a6,-(sp)
  623.         lea    mousey(pc),a1
  624.         move.w    d6,(a1)
  625.         cmp.l    #IDCMP_MENUVERIFY,d2
  626.         bne.w    .notmenuverify
  627.         lea    scrolla(pc),a0
  628.         clr.w    (a0)
  629. .notmenuverify
  630.         movem.l    (sp)+,a0/a6
  631.  
  632.     move.l    a0,a1
  633.     call    GT_ReplyIMsg
  634.  
  635.     pea    .return(pc)        ;-<>-
  636.  
  637.     cmp.l    #IDCMP_MENUPICK,d2
  638.     beq.B    menupick
  639.     cmp.l    #IDCMP_RAWKEY,d2
  640.     beq.w    rawkey
  641.     cmp.l    #IDCMP_VANILLAKEY,d2
  642.     beq.w    vanillakey
  643.     cmp.l    #IDCMP_REFRESHWINDOW,d2
  644.     beq.w    refreshwindow
  645.     cmp.l    #IDCMP_MOUSEMOVE,d2
  646.     beq.w    handlegadgets
  647.     cmp.l    #IDCMP_GADGETUP,d2
  648.     beq.w    handlegadgets
  649.     cmp.l    #IDCMP_MOUSEBUTTONS,d2
  650.     beq.w    handlebuttons
  651.     cmp.l    #IDCMP_INACTIVEWINDOW,d2
  652.     bne.w    .notinactive
  653.     lea    scrolla(pc),a0
  654.     clr.w    (a0)
  655. .notinactive
  656.  
  657.     addq.l    #4,sp            ;-<>-    clean up!
  658.  
  659.     bra.w    handleIDCMP
  660. .return
  661.     tst.l    d0
  662.     bne.b    .exit
  663.     bra.w    handleIDCMP
  664. .exit
  665.     rts
  666.  
  667. *********************************************************************** project
  668.  
  669. menupick:
  670. .loop
  671.     base    intui
  672.     moveq    #0,d0
  673.     move.w    d3,d0            ;code=menu number
  674.     move.l    winmenuptr(pc),a0
  675.     call    ItemAddress
  676.     lea    .item(pc),a0
  677.     move.l    d0,(a0)
  678.     move.l    d0,a0
  679.     move.l    d0,a1
  680.     cmp.w    #MENUNULL,d3
  681.     beq.b    .end
  682.     pea    .cont(pc)
  683.     GTMENUITEM_USERDATA    a1,a1
  684.     move.l    a1,d0            ;test!
  685.     beq.b    .end
  686.     jmp    (a1)            ;a0: pointer to menu structure
  687. .end
  688.     moveq    #0,d0
  689. .exit
  690.     rts
  691. .cont
  692.     tst.l    d0
  693.     bne.b    .exit
  694.     move.l    .item(pc),a0
  695.     move.w    mi_NextSelect(a0),d3
  696.     bra.B    .loop
  697. .item    dc.l    0
  698.  
  699. mnew:
  700.     bsr    multi_new
  701.     tst.l    d0
  702.     bne.b    .error
  703.     moveq    #1,d0
  704. .error
  705.     rts
  706. mopen:
  707.     moveq    #FALSE,d0            ;Open!
  708.     bsr.w    askfile
  709.     tst.l    d0
  710.     beq.b    .cancel
  711.     
  712.     bsr.w    openfile
  713. .cancel
  714.     moveq    #0,d0
  715.     rts
  716.  
  717. ;    lea    .thisbuff(pc),a0
  718. ;    move.l    thisbuff(pc),(a0)
  719. ;    move.l    coma_numargs(a0),d1
  720. ;    move.l    coma_arglist(a0),a2
  721. ;    bsr.w    parsewbarg
  722. ;    move.l    .thisbuff(pc),a5
  723. ;    bsr    multi_loadrest
  724.  
  725.  
  726. mopennew:
  727.     bsr    mnew
  728.     cmp.l    #1,d0
  729.     bne.b    .error
  730.     bsr.b    mopen
  731.     moveq    #1,d0
  732. .error
  733.     rts
  734.  
  735. msave:
  736.     lea    savetext(pc),a1
  737.     lea    savegadget(pc),a2
  738.     lea    .args(pc),a4
  739.     bsr    requester
  740.  
  741.     tst.l    d0
  742.     beq.b    .exit
  743.     lea    filereqdir(pc),a0
  744.     lea    filename(pc),a1
  745.     lea    temp,a2
  746.     move.w    #tempsize,d0
  747.     bsr.w    pathnfiletobuff
  748.  
  749.     move.l    #temp,d0
  750.     bsr    savefile
  751. .exit
  752.     moveq    #0,d0
  753.     rts
  754. .args
  755.     dc.l    filename
  756.  
  757. msaveas:
  758.     moveq    #TRUE,d0        ;Save!
  759.     bsr.w    askfile
  760.     tst.l    d0
  761.     beq.b    .cancel
  762.  
  763.     bsr.w    savefile
  764. .cancel
  765.     moveq    #0,d0
  766.     rts
  767. mprint:
  768.     jmp    printfile
  769. mprintas:
  770.     jsr    requestprintopts
  771.     subq.l    #1,d0
  772.     beq.b    mprint
  773.     moveq    #0,d0
  774.     rts
  775.  
  776. mreveal:
  777.     move.l    thisbuff(pc),a0
  778.     bsr    multi_curr2buff        ;update list!
  779.     jsr    requestreveal
  780.     tst.l    d0
  781.     bmi.s    .exit
  782.     beq.s    .cancel
  783.     move.l    bnum(pc),d0
  784.     subq.l    #1,d0
  785.     bsr    multi_change
  786.     bmi.b    .exit            ;can't happen.. (?) :)
  787. .cancel
  788.     moveq    #1,d0
  789. .exit
  790.     rts
  791.  
  792. mclose:
  793.     lea    bufflist(pc),a0
  794.     move.l    MLH_HEAD(a0),d0
  795.     cmp.l    MLH_TAILPRED(a0),d0
  796.     beq.w    mquit            ;quit last time
  797.  
  798.     bsr    multi_close
  799.     tst.l    d0
  800.     bne.b    .exit
  801.     bsr    updatemenu
  802.     moveq    #1,d0
  803. .exit
  804.     rts
  805.  
  806. miconify:
  807.     bsr.b    mopenwb
  808.     bra.w    iconify
  809.  
  810. mopenwb:
  811.     base    intui
  812.     call    OpenWorkBench
  813.     moveq    #0,d0
  814.     rts
  815.  
  816. mclosewb:
  817.     base    intui
  818.     call    CloseWorkBench
  819.     moveq    #0,d0
  820.     rts
  821.  
  822. mabout:
  823.     lea    .fill(pc),a4
  824.     move.l    filelen(pc),(a4)+
  825.     base    exec
  826.     moveq    #0,d1
  827.     call    AvailMem
  828.     move.l    d0,(a4)+
  829.     move.l    #MEMF_LARGEST,d1
  830.     call    AvailMem
  831.     move.l    d0,(a4)+
  832.     lea    abouttext(pc),a1
  833.     lea    oktext(pc),a2
  834.     lea    .args(pc),a4
  835.     bsr.w    requester
  836.     moveq    #0,d0
  837.     rts
  838. .args    dc.l    .releasestr
  839.     dc.l    .versionstr
  840.     dc.l    filename
  841. .fill    dc.l    0,0,0
  842.  
  843. .releasestr
  844.     releasestr
  845.     dc.b    0
  846. .versionstr    
  847.     versionstr
  848.     dc.b    "."
  849.     revisionstr
  850.     dc.b    0
  851.  
  852.     even
  853. mquit:
  854.     lea    status(pc),a0
  855.     bset    #s_exit,(a0)
  856.     moveq    #1,d0
  857. .exit
  858.     rts
  859.  
  860. ********************************************************************** settings
  861.  
  862. wordwrap:
  863.     dc.w    0
  864. mwordwrap:
  865.     lea    wordwrap(pc),a1
  866.     bsr.w    checkmark
  867.     tst.l    d0
  868.     beq.b    .nochange
  869.     bsr.w    countlines
  870.     tst.l    d0
  871.     bne.b    .exit
  872.     bsr.w    textredraw
  873. .nochange
  874.     moveq    #0,d0
  875. .exit
  876.     rts
  877. sysfont:
  878.     dc.w    0
  879. msysfont:
  880.     lea    sysfont(pc),a1
  881.     bsr.w    checkmark
  882.     tst.l    d0
  883.     beq.b    .nochange
  884.     bsr.w    changevideomode
  885.     tst.l    d0
  886.     bne.b    .exit
  887.     moveq    #1,d0
  888. .exit
  889.     rts
  890. .nochange
  891.     moveq    #0,d0
  892.     rts
  893. alwaysremansi:
  894.     dc.w    0
  895. malwaysremansi:
  896.     lea    alwaysremansi(pc),a1
  897.     bsr.w    checkmark
  898.     moveq    #0,d0
  899.     rts
  900. alwaysremcr:
  901.     dc.w    0
  902. malwaysremcr:
  903.     lea    alwaysremcr(pc),a1
  904.     bsr.w    checkmark
  905.     moveq    #0,d0
  906.     rts
  907. nofontfake:
  908.     dc.w    0
  909. mnofontfake:
  910.     lea    nofontfake(pc),a1
  911.     bsr.w    checkmark
  912.     tst.l    d0
  913.     beq.b    .nochange
  914.     moveq    #TRUE,d0
  915.     bsr.w    fixafonten
  916.     bsr    recountlines
  917.     bsr.w    textredraw
  918. .nochange
  919.     moveq    #0,d0
  920.     rts
  921. legalprint:
  922.     dc.w    0
  923. mlegalprint: 
  924.     lea    legalprint(pc),a1
  925.     bsr.w    checkmark
  926.     tst.l    d0
  927.     beq.b    .nochange
  928.     clr.w    oldfontsize        ;force update of font
  929.     tst.w    (a1)
  930.     beq.b    .fast
  931.     lea    nofontfake(pc),a0
  932.     move.w    #TRUE,(a0)
  933. .fast
  934.     bsr.w    updatemenu
  935.     bsr.w    updatecheckmarks
  936.  
  937.     moveq    #TRUE,d0
  938.     bsr.w    fixafonten
  939.     bsr    recountlines
  940.     bsr.w    textredraw
  941. .nochange
  942.     moveq    #0,d0
  943. .error
  944.     rts
  945. mtabsize:
  946.     jsr    requesttabsize
  947.     tst.l    d0
  948.     bmi.s    .exit
  949.     beq.s    .cancel
  950.     lea    tabbar,a0
  951.     bsr.w    fixatabbar
  952.     bsr.w    countlines
  953.     tst.l    d0
  954.     bne.b    .exit
  955. .ok
  956.     bsr.w    textredraw
  957. .cancel
  958.     moveq    #0,d0
  959. .exit
  960.     rts
  961. ;in:
  962. * a0    pek på (word) strukt: MinX, MinY, MaxX, MaxY
  963. getfontlimits:
  964.     move.l    a0,a1
  965.     moveq    #8,d0
  966.     move.w    d0,(a0)+
  967.     move.w    d0,(a0)+
  968.     move.w    d0,(a0)+
  969.     move.w    d0,(a0)+
  970.  
  971.     lea    legalprint(pc),a0
  972.     tst.w    (a0)
  973.     beq.b    .exit
  974.  
  975.     move.l    pwidth(pc),d0
  976.     divu.w    #254,d0            ;max chars/row
  977.     cmp.w    #5,d0
  978.     bpl.b    .xgt5
  979.     moveq    #5,d0
  980. .xgt5
  981.     move.w    d0,(a1)            ;MinX
  982.  
  983.     move.l    pwidth(pc),d0
  984.     divu.w    #80,d0            ;min chars/row
  985.     move.w    d0,4(a1)        ;MaxX
  986.  
  987.     move.l    pheight(pc),d0
  988.     sub.l    barheight(pc),d0
  989.     sub.l    fonty(pc),d0
  990.     subq.l    #4,d0            ;space for bevelbox
  991.     move.l    d0,d1
  992.  
  993.     divu.w    #254,d1            ;max rows
  994.     cmp.w    #5,d1
  995.     bpl.b    .ygt5
  996.     moveq    #5,d1
  997. .ygt5
  998.     move.w    d1,2(a1)        ;MinY
  999.  
  1000.     divu.w    #20,d0            ;min rows
  1001.     move.w    d0,6(a1)        ;MaxY
  1002. .exit
  1003.     rts
  1004.  
  1005. mscreen:
  1006.     base    asl
  1007.     cmp.w    #38,LIB_VERSION(a6)
  1008.     bhs.w    .v38
  1009.     lea    smodetext(pc),a1
  1010.     lea    smodegadget(pc),a2
  1011.     suba.l    a4,a4
  1012.     bsr    requester
  1013.     tst.l    d0
  1014.     beq.w    .error
  1015.     lea    displayid(pc),a0
  1016.     cmp.w    #1,d0
  1017.     bne.w    .not_pal
  1018.     move.l    #PAL_MONITOR_ID|HIRES_KEY,(a0)
  1019. .not_pal
  1020.     cmp.w    #2,d0
  1021.     bne.w    .not_pal_lace
  1022.     move.l    #PAL_MONITOR_ID|HIRESLACE_KEY,(a0)
  1023. .not_pal_lace
  1024.     cmp.w    #3,d0
  1025.     bne.w    .not_ntsc
  1026.     move.l    #NTSC_MONITOR_ID|HIRES_KEY,(a0)
  1027. .not_ntsc
  1028.     cmp.w    #4,d0
  1029.     bne.w    .not_ntsc_lace
  1030.     move.l    #NTSC_MONITOR_ID|HIRESLACE_KEY,(a0)
  1031. .not_ntsc_lace
  1032.     cmp.w    #5,d0
  1033.     bne.w    .not_vga_prod
  1034.     move.l    #VGA_MONITOR_ID|VGAPRODUCT_KEY,(a0)
  1035. .not_vga_prod
  1036.     bra.w    .changeit
  1037. .v38
  1038.     lea    .tagswin(pc),a0
  1039.     move.l    windowptr(pc),(a0)
  1040.     lea    .tagsdispid(pc),a0
  1041.     move.l    displayid(pc),(a0)
  1042.  
  1043.     lea    .scrnreqhgt(pc),a0
  1044.     move.l    pheight(pc),d0
  1045.     mulu    #7,d0
  1046.     lsr.l    #3,d0
  1047.     move.l    d0,(a0)
  1048.  
  1049.     moveq    #ASL_ScreenModeRequest,d0
  1050.     lea    .tags(pc),a0
  1051.     call    AllocAslRequest
  1052.     lea    .screenreq(pc),a0
  1053.     move.l    d0,(a0)
  1054.     beq.w    .error
  1055.  
  1056.     move.l    .screenreq(pc),a0
  1057.     lea    tag_done(pc),a1
  1058.     call    AslRequest
  1059.     tst.l    d0
  1060.     beq.b    .cancel
  1061.  
  1062.     move.l    .screenreq(pc),a0
  1063.     lea    displayid(pc),a1
  1064.     move.l    sm_DisplayID(a0),(a1)
  1065.     base    asl
  1066.     move.l    .screenreq(pc),a0
  1067.     call    FreeAslRequest
  1068. .changeit
  1069.     bsr.w    changevideomode
  1070.     tst.l    d0
  1071.     bne.b    .exit
  1072.     moveq    #1,d0            ;process no more menus
  1073. .exit
  1074.     rts
  1075. .cancel
  1076.     base    asl
  1077.     move.l    .screenreq(pc),a0
  1078.     call    FreeAslRequest
  1079. .error
  1080.     moveq    #0,d0
  1081.     rts
  1082. .screenreq
  1083.     dc.l    0
  1084. .tags
  1085.     dc.l    ASLSM_Window
  1086. .tagswin
  1087.     dc.l    0
  1088.     dc.l    ASLSM_SleepWindow,TRUE
  1089.     dc.l    ASLSM_InitialDisplayID
  1090. .tagsdispid
  1091.     dc.l    0
  1092.     dc.l    ASLSM_PropertyFlags,DIPF_IS_WB
  1093.     dc.l    ASLSM_PropertyMask,DIPF_IS_WB
  1094.     dc.l    ASLSM_FilterFunc,.hook
  1095.     dc.l    ASLSM_InitialHeight
  1096. .scrnreqhgt
  1097.     dc.l    100
  1098.     dc.l    TAG_DONE
  1099.  
  1100. .entry
  1101.     move.l    h_SubEntry(a0),a0
  1102.     jsr    (a0)
  1103.     rts
  1104. .subentry
  1105.     move.l    a6,-(sp)
  1106.     base    intui
  1107.     move.l    a1,a0            ;displayid
  1108.     lea    temp,a1
  1109.     clr.l    (a1)
  1110.     clr.l    4(a1)            ;just some cleanup
  1111.     moveq    #OSCAN_TEXT,d0
  1112.     call    QueryOverscan
  1113.  
  1114.     lea    temp,a0
  1115.     move.w    ra_MaxX(a0),d0
  1116.     sub.w    ra_MinX(a0),d0
  1117.     cmp.w    #639,d0
  1118.     blo.s    .false
  1119.     move.w    ra_MaxY(a0),d0
  1120.     sub.w    ra_MinY(a0),d0
  1121.     cmp.w    #199,d0
  1122.     blo.s    .false
  1123.  
  1124.     move.l    (sp)+,a6
  1125.     moveq    #TRUE,d0
  1126.     rts
  1127. .false
  1128.     move.l    (sp)+,a6
  1129.     moveq    #FALSE,d0
  1130.     rts
  1131. .hook
  1132.     ds.b    MLN_SIZE
  1133.     dc.l    .entry
  1134.     dc.l    .subentry
  1135.     dc.l    NULL
  1136.  
  1137. mscreencol:
  1138.     bsr    lockwindow
  1139.     base    dos
  1140.     lea    .command(pc),a0
  1141.     move.l    a0,d1
  1142.     lea    .tags(pc),a0
  1143.     move.l    a0,d2
  1144.     call    SystemTagList
  1145.     tst.l    d0
  1146.     beq.b    .exit
  1147.     bsr    unlockwindow
  1148.     lea    colerrortext(pc),a1
  1149.     lea    oktext(pc),a2
  1150.     suba.l    a4,a4
  1151.     bsr    requester
  1152.     bsr    lockwindow
  1153. .exit
  1154.     lea    palette(pc),a1
  1155.     bsr    getpalette
  1156.     bsr    unlockwindow
  1157.     moveq    #0,d0
  1158.     rts
  1159.  
  1160. .command
  1161.     dc.b    "SYS:Tools/Colors",0
  1162.     even
  1163. .tags    
  1164.     dc.l    SYS_UserShell,TRUE
  1165.     dc.l    TAG_DONE
  1166.  
  1167. mdefcol:
  1168.     lea    defpalette,a1
  1169.     bsr    changepalette
  1170.     moveq    #0,d0
  1171.     rts
  1172.  
  1173. mtextfont:
  1174.     lea    .minx(pc),a0
  1175.     bsr    getfontlimits
  1176.  
  1177.     lea    .freqminheight+2(pc),a0
  1178.     move.w    .miny(pc),(a0)
  1179.     lea    .freqmaxheight+2(pc),a0
  1180.     move.w    .maxy(pc),(a0)
  1181.  
  1182.     lea    savedfont,a0
  1183.     lea    savedfontname,a1
  1184.     bsr.w    savefont
  1185.  
  1186.     lea    .freqdefheight(pc),a0
  1187.     move.w    thisfont+ta_YSize(pc),2(a0)
  1188.     lea    .window(pc),a0
  1189.     move.l    windowptr(pc),(a0)
  1190.     lea    .fontreqhgt(pc),a0
  1191.     move.l    pheight(pc),d0
  1192.     mulu    #7,d0
  1193.     lsr.l    #3,d0
  1194.     move.l    d0,(a0)
  1195.  
  1196.     base    asl
  1197.     moveq    #ASL_FontRequest,d0
  1198.     lea    .tags(pc),a0
  1199.     call    AllocAslRequest
  1200.     lea    .fontreqptr(pc),a0
  1201.     move.l    d0,(a0)
  1202.     beq.s    .exit
  1203. .selectagain
  1204.     base    asl
  1205.     move.l    .fontreqptr(pc),a0
  1206.     lea    tag_done(pc),a1
  1207.     call    AslRequest
  1208.     tst.l    d0
  1209.     beq.B    .cancel
  1210.  
  1211.     move.l    .fontreqptr(pc),a0
  1212.     lea    fo_Attr(a0),a0
  1213.  
  1214.     bsr.w    changefont
  1215.     tst.l    d0
  1216.     bne.b    .selectagain
  1217.  
  1218.     move.l    myfont(pc),a1
  1219.  
  1220.     move.w    .miny(pc),d0
  1221.     cmp.w    tf_YSize(a1),d0
  1222.     bhi.b    .selectagain        ;<min?
  1223.     move.w    .maxy(pc),d0
  1224.     cmp.w    tf_YSize(a1),d0
  1225.     blo.b    .selectagain        ;>max?
  1226.  
  1227.     move.w    .minx(pc),d0
  1228.     cmp.w    tf_XSize(a1),d0
  1229.     bhi.b    .selectagain        ;<min?
  1230.     move.w    .maxx(pc),d0
  1231.     cmp.w    tf_XSize(a1),d0
  1232.     blo.b    .selectagain        ;>max?
  1233.     bra.s    .exit
  1234. .cancel
  1235.     lea    savedfont,a0
  1236.     bsr.w    changefont
  1237. .exit
  1238.     base    asl
  1239.     move.l    .fontreqptr(pc),a0
  1240.     clr.l    .fontreqptr
  1241.     call    FreeAslRequest
  1242.  
  1243.     moveq    #FALSE,d0
  1244.     bsr.w    fixafonten
  1245.     bsr    recountlines
  1246.     bsr.w    textredraw
  1247.     moveq    #0,d0
  1248. .error
  1249.     rts
  1250.  
  1251. .minx    dc.w    0
  1252. .miny    dc.w    0
  1253. .maxx    dc.w    0
  1254. .maxy    dc.w    0
  1255.  
  1256. .entry
  1257.     base    diskfont
  1258.     move.l    a6,d0
  1259.     beq.b    .hookrettrue        ;If no diskfont.library, return(1)
  1260.  
  1261.     btst.b    #FPB_PROPORTIONAL,ta_Flags(a1)
  1262.     bne.b    .hookfelfont
  1263.  
  1264.     move.w    .miny(pc),d0
  1265.     cmp.w    ta_YSize(a1),d0
  1266.     bhi.b    .hookfelfont        ;<min?
  1267.     move.w    .maxy(pc),d0
  1268.     cmp.w    ta_YSize(a1),d0
  1269.     blo.b    .hookfelfont        ;>max?
  1270.  
  1271.     move.l    a1,a0
  1272.     call    OpenDiskFont
  1273.     tst.l    d0
  1274.     beq.b    .hookrettrue        ;If error, return(1)
  1275.     move.l    d0,a0
  1276.  
  1277.     move.w    tf_XSize(a0),d2
  1278.  
  1279.     base    gfx
  1280.     move.l    d0,a1
  1281.     call    CloseFont
  1282.  
  1283.     move.w    .minx(pc),d0
  1284.     cmp.w    d2,d0
  1285.     bhi.b    .hookfelfont        ;<min?
  1286.     move.w    .maxx(pc),d0
  1287.     cmp.w    d2,d0
  1288.     blo.b    .hookfelfont        ;>max?
  1289.  
  1290. .hookrettrue
  1291.     moveq    #TRUE,d0
  1292.     rts
  1293. .hookfelfont
  1294.     moveq    #FALSE,d0
  1295.     rts
  1296. .hook
  1297.     ds.b    MLN_SIZE
  1298.     dc.l    .entry
  1299.     dc.l    NULL
  1300.     dc.l    NULL
  1301. .tags
  1302.     dc.l    ASLFO_Window
  1303. .window    dc.l    0
  1304.     dc.l    ASLFO_SleepWindow,TRUE
  1305.     dc.l    ASLFO_FixedWidthOnly,TRUE
  1306.     dc.l    ASLFO_InitialSize
  1307. .freqdefheight
  1308.     dc.l    8
  1309.     dc.l    ASLFO_InitialName,thisfontname
  1310.     dc.l    ASLFO_MinHeight
  1311. .freqminheight
  1312.     dc.l    8
  1313.     dc.l    ASLFO_MaxHeight
  1314. .freqmaxheight
  1315.     dc.l    8
  1316.     dc.l    ASLFO_FilterFunc,.hook
  1317.     dc.l    ASLFO_InitialHeight
  1318. .fontreqhgt
  1319.     dc.l    100
  1320.     dc.l    TAG_DONE
  1321. .fontreqptr    dc.l    0
  1322.     even
  1323.  
  1324. mdeffont:
  1325.     lea    legalprint(pc),a0
  1326.     tst.w    (a0)
  1327.     bne.b    .legal
  1328.  
  1329.     lea    topaz8font(pc),a0
  1330.     bsr.w    changefont
  1331.     bra.b    .fontok
  1332. .legal
  1333.     lea    deffont,a0
  1334.     bsr.w    changefont
  1335. .fontok
  1336.     moveq    #FALSE,d0
  1337.     bsr.w    fixafonten
  1338.     bsr    recountlines
  1339.     bsr.w    textredraw
  1340.     moveq    #0,d0
  1341. .error
  1342.     rts
  1343.  
  1344. mloadset:
  1345. .again
  1346.     lea    setfreqtitle(pc),a0
  1347.     lea    loadsettitle(pc),a1
  1348.     move.l    a1,(a0)
  1349.     move.l    #FALSE,setfreqsave
  1350.     base    asl
  1351.     move.l    setfreqptr(pc),a0
  1352.     lea    setfreqtags(pc),a1
  1353.     call    AslRequest
  1354.     tst.l    d0
  1355.     beq.s    .error
  1356.  
  1357.     move.l    setfreqptr(pc),a0
  1358.     move.l    fr_File(a0),a1
  1359.     move.l    fr_Drawer(a0),a0
  1360.     lea    temp,a2
  1361.     move.w    #tempsize,d0
  1362.     bsr.w    pathnfiletobuff
  1363.  
  1364.     lea    temp,a0
  1365.     bsr    loadsettings
  1366.     tst.l    d0
  1367.     bne.b    .again            ;error!
  1368.     bsr.w    mloadset_changeenv
  1369.     tst.l    d0
  1370.     bne.b    .error
  1371. .exit
  1372.     moveq    #0,d0
  1373. .error
  1374.     rts
  1375.  
  1376. ;in:
  1377. * d1    gammal sysfont
  1378. * d2    gammal screenmode
  1379. mloadset_changeenv:
  1380.     bsr    prefs2curr
  1381.  
  1382.     bsr    changeenv
  1383.     tst.l    d0
  1384.     bne.b    .error
  1385.     bsr.w    recountlines
  1386.     tst.l    d0
  1387.     bne.b    .error
  1388.  
  1389.     moveq    #1,d0
  1390. .error
  1391.     rts
  1392.  
  1393. msaveset:
  1394.     lea    setname,a0
  1395.     tst.b    (a0)
  1396.     bne.b    .saveit
  1397.  
  1398.     base    dos
  1399.     lea    defsetname(pc),a2
  1400.     move.l    a2,d1
  1401.     call    PathPart
  1402.     lea    temp,a0
  1403.     move.l    a2,a1
  1404. .loop
  1405.     move.b    (a1)+,(a0)+
  1406.     cmp.l    a1,d0
  1407.     bne.b    .loop
  1408.     clr.b    (a0)
  1409.     move.l    #temp,d1
  1410.     moveq    #ACCESS_READ,d2
  1411.     call    Lock
  1412.     tst.l    d0
  1413.     bne.b    .unlock
  1414.     move.l    #temp,d1
  1415.     call    CreateDir
  1416. .unlock
  1417.     move.l    d0,d1
  1418.     call    UnLock                ;NULL is ok
  1419.  
  1420.     move.l    a2,a0
  1421. .saveit
  1422.     bsr.w    savesettings
  1423.     tst.l    d0
  1424.     beq.b    .exit
  1425.     lea    savesetmessage(pc),a1
  1426.     lea    oktext(pc),a2
  1427.     suba.l    a4,a4
  1428.     bsr    requester
  1429. .exit
  1430.     moveq    #0,d0
  1431.     rts
  1432. msavesetas:
  1433. .again
  1434.     lea    setfreqtitle(pc),a0
  1435.     lea    savesettitle(pc),a1
  1436.     move.l    a1,(a0)
  1437.     move.l    #TRUE,setfreqsave
  1438.     base    asl
  1439.     move.l    setfreqptr(pc),a0
  1440.     lea    setfreqtags(pc),a1
  1441.     call    AslRequest
  1442.     tst.l    d0
  1443.     beq.s    .error
  1444.  
  1445.     move.l    setfreqptr(pc),a0
  1446.     move.l    fr_File(a0),a1
  1447.     move.l    fr_Drawer(a0),a0
  1448.     lea    temp,a2
  1449.     move.w    #tempsize,d0
  1450.     bsr.w    pathnfiletobuff
  1451.  
  1452.     lea    temp,a0
  1453.     bsr.W    savesettings
  1454.     tst.l    d0
  1455.     bmi.b    .again
  1456. .exit
  1457.     moveq    #0,d0
  1458. .error
  1459.     rts
  1460.  
  1461. ;in:
  1462. * a0    filename
  1463. ;ut:
  1464. * d0    0 if no error, else -1
  1465. loadsettings:
  1466.     pushm    d1-a6
  1467.  
  1468.     lea    .filename(pc),a1
  1469.     move.l    a0,(a1)
  1470.  
  1471.     bsr    curr2prefs
  1472.  
  1473.     move.l    .filename(pc),a0
  1474.     bsr    loadfile
  1475.     tst.l    d0
  1476.     bne.w    .error
  1477.     lea    .addr(pc),a1
  1478.     move.l    a0,(a1)
  1479.     lea    .memlen(pc),a1
  1480.     move.l    d1,(a1)
  1481.     lea    .len(pc),a1
  1482.     move.l    d2,(a1)
  1483.  
  1484.     lea    prefs_id(pc),a1
  1485. .testloop
  1486.     move.b    (a1)+,d0
  1487.     beq.b    .testok
  1488.     cmp.b    (a0)+,d0
  1489.     bne.w    .error
  1490.     bra.b    .testloop
  1491. .testok
  1492.  
  1493.     base    dos
  1494.  
  1495.     lea    prefs_longs(pc),a2
  1496. .longloop
  1497.     move.l    (a2)+,d0
  1498.     beq.b    .nomorelongs
  1499.     move.l    d0,a1
  1500.     move.l    .addr(pc),a0
  1501.     move.l    .len(pc),d0
  1502.     bsr    .getarg
  1503.     move.l    (a2)+,d2
  1504.     move.l    d0,d1
  1505.     beq.b    .longloop
  1506.     call    StrToLong
  1507.     bra.b    .longloop
  1508. .nomorelongs
  1509.  
  1510.     lea    prefs_words(pc),a2
  1511. .wordloop
  1512.     move.l    (a2)+,d0
  1513.     beq.b    .nomorewords
  1514.     move.l    d0,a1
  1515.     move.l    .addr(pc),a0
  1516.     move.l    .len(pc),d0
  1517.     bsr    .getarg
  1518.     move.l    (a2)+,a3
  1519.     lea    .templong(pc),a0
  1520.     move.l    a0,d2
  1521.     move.l    d0,d1
  1522.     beq.b    .wordloop
  1523.     call    StrToLong
  1524.     move.w    .templong+2(pc),(a3)
  1525.     bra.b    .wordloop
  1526. .nomorewords
  1527.  
  1528.     lea    prefs_strings(pc),a2
  1529. .stringloop
  1530.     move.l    (a2)+,d0
  1531.     beq.b    .nomorestrings
  1532.     move.l    d0,a1
  1533.     move.l    .addr(pc),a0
  1534.     move.l    .len(pc),d0
  1535.     bsr    .getarg
  1536.     move.l    (a2)+,a1
  1537.     tst.l    d0
  1538.     beq.b    .stringloop
  1539.     move.l    d0,a0
  1540. .stringcopy
  1541.     move.b    (a0)+,d0
  1542.     cmp.b    #LF,d0
  1543.     bne.b    .stringnolf
  1544.     moveq    #0,d0
  1545. .stringnolf
  1546.     move.b    d0,(a1)+
  1547.     bne.b    .stringcopy
  1548.     bra.b    .stringloop
  1549. .nomorestrings
  1550.  
  1551.  
  1552.     lea    prefs_palette(pc),a1
  1553.     move.l    .addr(pc),a0
  1554.     move.l    .len(pc),d0
  1555.     bsr    .getarg
  1556.     move.l    d0,d3
  1557.     beq.b    .nopalette
  1558.     lea    palette(pc),a2
  1559.     moveq    #3*4-1,d4
  1560. .paletteloop
  1561.     move.l    a2,d2
  1562.     move.l    d3,d1
  1563.     bsr    strtoulong
  1564.     addq.l    #1,d0
  1565.     beq.b    .nopalette
  1566.     addq.l    #1,d0
  1567.     add.l    d0,d3
  1568.     addq.l    #4,a2
  1569.     dbf    d4,.paletteloop
  1570. .nopalette
  1571.     lea    thisfont(pc),a0
  1572.     lea    thisfontname(pc),a1
  1573.     move.l    a1,(a0)
  1574.  
  1575.     move.w    #setnamelen-1,d0    ;save the name
  1576.     lea    setname,a1
  1577.     move.l    .filename(pc),a0
  1578. .copysetname
  1579.     move.b    (a0)+,(a1)+
  1580.     dbeq    d0,.copysetname
  1581.  
  1582.     moveq    #0,d2
  1583. .exit
  1584.     base    exec
  1585.     move.l    .addr(pc),a1
  1586.     move.l    .memlen(pc),d0
  1587.     beq.b    .nofileloaded
  1588.     call    FreeMem
  1589. .nofileloaded
  1590.     move.l    d2,d0
  1591.     popm    d1-a6
  1592.     rts
  1593. .error
  1594.     moveq    #-1,d2
  1595.     bra.b    .exit
  1596. .filehandle    dc.l    0
  1597. .filename    dc.l    0
  1598. .addr        dc.l    0
  1599. .memlen        dc.l    0
  1600. .len        dc.l    0
  1601. .templong    dc.l    0
  1602. ;in:
  1603. * a0    buffer to search
  1604. * a1    NULL-terminated keyword
  1605. * d0    length of buffer
  1606. ;ut:
  1607. * d0    pointer to argument or NULL if not found
  1608. .getarg
  1609.     pushm    d1/a0-a3
  1610.     subq.w    #1,d0
  1611. .getarg_loop2
  1612.     move.b    (a1),d1
  1613. .getarg_loop1
  1614.     cmp.b    (a0)+,d1
  1615.     dbeq    d0,.getarg_loop1
  1616.     tst.w    d0
  1617.     bmi.b    .getarg_notfound
  1618.  
  1619.     move.l    a0,a2
  1620.     move.l    a1,a3
  1621.     addq.l    #1,a3
  1622. .getarg_loop3
  1623.     move.b    (a3)+,d1
  1624.     beq.b    .getarg_found
  1625.     cmp.b    (a2)+,d1
  1626.     beq.b    .getarg_loop3
  1627.     bra.b    .getarg_loop2
  1628. .getarg_found
  1629.     move.l    a2,d0
  1630.     addq.l    #1,d0
  1631.     bra.b    .getarg_exit
  1632. .getarg_notfound
  1633.     moveq    #0,d0
  1634. .getarg_exit
  1635.     popm    d1/a0-a3
  1636.     rts
  1637.  
  1638. in:
  1639. * a0    filename
  1640. ;ut:
  1641. * d0    0 if no error, else -1
  1642. savesettings:
  1643.     bsr    curr2prefs
  1644.     base    dos
  1645.     move.l    a0,d1
  1646.     lea    .filename(pc),a1
  1647.     move.l    a0,(a1)
  1648.     move.l    #MODE_NEWFILE,d2
  1649.     call    Open
  1650.     lea    .filehandle(pc),a0
  1651.     move.l    d0,(a0)
  1652.     beq.w    .error
  1653.     move.l    d0,d3
  1654.     lea    prefs_id(pc),a0
  1655.     move.l    a0,d2
  1656.     move.l    d3,d1
  1657.     call    FPuts
  1658.     lea    prefs_version(pc),a0
  1659.     move.l    a0,d2
  1660.     move.l    d3,d1
  1661.     call    FPuts
  1662.  
  1663.     lea    prefs_longs(pc),a2
  1664. .longloop
  1665.     move.l    (a2)+,d2
  1666.     beq.b    .nomorelongs
  1667.     move.l    d3,d1
  1668.     call    FPuts
  1669.     move.l    d3,d1
  1670.     moveq    #"=",d2
  1671.     call    FPutC
  1672.     move.l    (a2)+,a0
  1673.     move.l    (a0),d0
  1674.     bsr    numdec
  1675.     move.l    d0,d2
  1676.     move.l    d3,d1
  1677.     call    FPuts
  1678.     move.l    d3,d1
  1679.     moveq    #LF,d2
  1680.     call    FPutC
  1681.     bra.b    .longloop
  1682. .nomorelongs
  1683.  
  1684.     lea    prefs_words(pc),a2
  1685. .wordloop
  1686.     move.l    (a2)+,d2
  1687.     beq.b    .nomorewords
  1688.     move.l    d3,d1
  1689.     call    FPuts
  1690.     move.l    d3,d1
  1691.     moveq    #"=",d2
  1692.     call    FPutC
  1693.     move.l    (a2)+,a0
  1694.     moveq    #0,d0
  1695.     move.w    (a0),d0
  1696.     bsr    numdec
  1697.     move.l    d0,d2
  1698.     move.l    d3,d1
  1699.     call    FPuts
  1700.     move.l    d3,d1
  1701.     moveq    #LF,d2
  1702.     call    FPutC
  1703.     bra.b    .wordloop
  1704. .nomorewords
  1705.  
  1706.     lea    prefs_strings(pc),a2
  1707. .stringloop
  1708.     move.l    (a2)+,d2
  1709.     beq.b    .nomorestrings
  1710.     move.l    d3,d1
  1711.     call    FPuts
  1712.     move.l    d3,d1
  1713.     moveq    #"=",d2
  1714.     call    FPutC
  1715.     move.l    (a2)+,d2
  1716.     move.l    d3,d1
  1717.     call    FPuts
  1718.     move.l    d3,d1
  1719.     moveq    #LF,d2
  1720.     call    FPutC
  1721.     bra.b    .stringloop
  1722. .nomorestrings
  1723.  
  1724.     lea    prefs_palette(pc),a0
  1725.     move.l    d3,d1
  1726.     move.l    a0,d2
  1727.     call    FPuts
  1728.     move.l    d3,d1
  1729.     moveq    #"=",d2
  1730.     call    FPutC
  1731.     lea    palette(pc),a2
  1732.     move.l    (a2)+,d0
  1733.     bsr    numdec
  1734.     move.l    d0,d2
  1735.     move.l    d3,d1
  1736.     call    FPuts
  1737.     moveq    #4*3-1-1,d4
  1738. .paletteloop
  1739.     move.l    d3,d1
  1740.     moveq    #",",d2
  1741.     call    FPutC
  1742.     move.l    (a2)+,d0
  1743.     bsr    numdec
  1744.     move.l    d0,d2
  1745.     move.l    d3,d1
  1746.     call    FPuts
  1747.     dbf    d4,.paletteloop
  1748.     move.l    d3,d1
  1749.     moveq    #LF,d2
  1750.     call    FPutC
  1751.  
  1752.     lea    createicons(pc),a0
  1753.     tst.w    (a0)
  1754.     beq.b    .noicon
  1755.     base    icon
  1756.     lea    .defprefsiconname(pc),a0
  1757.     call    GetDiskObject
  1758.     move.l    d0,d2
  1759.     move.l    d0,a1
  1760.     bne.b    .nodefprefsicon
  1761.     lea    Textread_prefs,a1    ;builtin icon
  1762. .nodefprefsicon
  1763.     move.l    .filename(pc),a0
  1764.     call    PutDiskObject
  1765.     tst.l    d2
  1766.     beq.b    .nodefprefsicon2
  1767.     move.l    d2,a0
  1768.     call    FreeDiskObject
  1769. .nodefprefsicon2
  1770. .noicon
  1771.     base    dos
  1772.     move.l    .filehandle(pc),d1
  1773.     call    Close
  1774.  
  1775.     move.l    .filename(pc),a0
  1776.     lea    setname,a1
  1777. .copysetname
  1778.     move.b    (a0)+,(a1)+
  1779.     bne.b    .copysetname
  1780.  
  1781.     moveq    #0,d0
  1782.     rts
  1783. .error
  1784.     moveq    #-1,d0
  1785.     rts
  1786.  
  1787. .filehandle    dc.l    0
  1788. .filename    dc.l    0
  1789. .defprefsiconname
  1790.     dc.b    "ENV:Textread/def_prefs",0
  1791.     even
  1792.  
  1793. prefs_longs
  1794.     dc.l    prefs_tabsize,tabsize
  1795.     dc.l    prefs_displayid,setdisplayid
  1796.     dc.l    0
  1797. prefs_words
  1798.     dc.l    prefs_fontsize,thisfontsize
  1799.     dc.l    prefs_createicons,setcreateicons
  1800.     dc.l    prefs_wordwrap,setwordwrap
  1801.     dc.l    prefs_sysfont,setsysfont
  1802.     dc.l    prefs_remansi,setalwaysremansi
  1803.     dc.l    prefs_remcr,setalwaysremcr
  1804.     dc.l    prefs_nofontfake,setnofontfake
  1805.     dc.l    prefs_legalprint,setlegalprint
  1806.     dc.l    0
  1807. prefs_strings
  1808.     dc.l    prefs_fontname,thisfontname
  1809.     dc.l    prefs_filereqdir,filereqdir
  1810.     dc.l    prefs_filereqpat,filereqpat
  1811.     dc.l    0
  1812.  
  1813. prefs_id    dc.b    "Textread settings",10,0
  1814. prefs_id_len    =*-prefs_id
  1815.  
  1816. prefs_version
  1817.     dc.b    "$VER: Textread "
  1818.     versionstr
  1819.     dc.b    "."
  1820.     revisionstr
  1821.     dc.b    " ("
  1822.     date
  1823.     dc.b    ")",10,10,0
  1824.  
  1825. prefs_tabsize        dc.b    "TABSIZE",0
  1826. prefs_fontname        dc.b    "FONTNAME",0
  1827. prefs_fontsize        dc.b    "FONTSIZE",0
  1828. prefs_filereqdir    dc.b    "REQDIR",0
  1829. prefs_filereqpat    dc.b    "REQPATTERN",0
  1830. prefs_createicons    dc.b    "CREATEICONS",0
  1831. prefs_wordwrap        dc.b    "WORDWRAP",0
  1832. prefs_sysfont        dc.b    "SYSFONT",0
  1833. prefs_remansi        dc.b    "REMANSI",0
  1834. prefs_remcr        dc.b    "REMCR",0
  1835. prefs_nofontfake    dc.b    "NOFONTFAKE",0
  1836. prefs_legalprint    dc.b    "LEGALPRINT",0
  1837. prefs_displayid        dc.b    "DISPLAYID",0
  1838. prefs_palette        dc.b    "PALETTE",0
  1839.     even
  1840.  
  1841. createicons:
  1842.     dc.w    0
  1843. mcreateicons:
  1844.     lea    createicons(pc),a1
  1845.     bsr.w    checkmark
  1846.     moveq    #0,d0
  1847.     rts
  1848.  
  1849. mprefs2all:
  1850.     bsr    multi_prefs2all
  1851.     moveq    #0,d0
  1852.     rts
  1853.  
  1854. ********************************************************************** commands
  1855.  
  1856. msearch:
  1857.     bra.w    search
  1858. msearchnext:
  1859.     bra.w    searchnext
  1860. msearchprev:
  1861.     bra.w    searchprev
  1862.  
  1863. medittext:
  1864.     bra.w    vedittext
  1865. mremansi:
  1866.     bsr.b    RemoveANSI
  1867.     bsr.w    countlines
  1868.     tst.l    d0
  1869.     bne.b    .error
  1870.     bsr.w    textredraw
  1871.     moveq    #0,d0
  1872. .error
  1873.     rts
  1874. mremcr:
  1875.     bsr.w    RemoveCR
  1876.     bsr.w    countlines
  1877.     tst.l    d0
  1878.     bne.b    .error
  1879.     bsr.w    textredraw
  1880.     moveq    #0,d0
  1881. .error
  1882.     rts
  1883.  
  1884. RemoveANSI:
  1885.     tst.l    filememlen
  1886.     beq.b    .exit
  1887.     Message    remansitext
  1888.     move.l    fileaddr(pc),a0
  1889.     move.l    a0,a1
  1890.     add.l    filelen(pc),a1
  1891.     bsr.b    .RemoveANSI
  1892.     move.l    fileaddr(pc),d1
  1893.     sub.l    d1,d0
  1894.     lea    filelen(pc),a0
  1895.     move.l    d0,(a0)
  1896.     Message    screentitle
  1897. .exit
  1898.     moveq    #0,d0
  1899.     rts
  1900.     even
  1901. ;in:
  1902. * a0    text
  1903. * a1    textend
  1904. ;ut:
  1905. * d0    nytt textend
  1906. .RemoveANSI
  1907.     move.l    a0,a2
  1908.     move.l    a0,a4            ;save beginning
  1909.     moveq    #$1b,d7            ;ESC
  1910.     moveq    #$9b-256,d6        ;CSI    (moveq.b #$9b,d6)
  1911.     moveq    #8,d5            ;BS
  1912. .loop
  1913.     move.b    (a0)+,d0
  1914.     cmp.b    d7,d0            ;Esc
  1915.     bne.b    .inteESC
  1916.  
  1917.     move.l    a0,a3
  1918.  
  1919.     move.b    (a3)+,d1
  1920.  
  1921.     cmp.b    #"[",d1
  1922.     beq.b    .csi_loop        ;*NOT* ISO/ANSI, but often used.
  1923.  
  1924.     cmp.b    #" ",d1
  1925.     blo.b    .dontremove
  1926.     cmp.b    #"/",d1
  1927.     bhi.b    .dontremove
  1928.  
  1929. .esc_loop
  1930.     move.b    (a3)+,d1
  1931.     cmp.b    #" ",d1
  1932.     blo.b    .esc_last
  1933.     cmp.b    #"/",d1
  1934.     bhi.b    .esc_last
  1935.     cmp.l    a1,a3
  1936.     blo.b    .esc_loop
  1937.     bra.b    .dontremove
  1938. .esc_last
  1939.     move.b    -1(a3),d1
  1940.     cmp.b    #"0",d1
  1941.     blo.b    .dontremove
  1942.     cmp.b    #"~",d1
  1943.     bhi.b    .dontremove
  1944.  
  1945.     move.l    a3,a0            ;Remove!
  1946.     bra.b    .nextchar
  1947. .inteESC
  1948.     cmp.b    d6,d0            ;CSI
  1949.     bne.b    .inteCSI
  1950.  
  1951.     move.l    a0,a3
  1952.  
  1953.     move.b    (a3)+,d1
  1954.     cmp.b    #" ",d1
  1955.     blo.b    .dontremove
  1956.     cmp.b    #"?",d1
  1957.     bhi.b    .dontremove
  1958.  
  1959. .csi_loop
  1960.     move.b    (a3)+,d1
  1961.     cmp.b    #" ",d1
  1962.     blo.b    .csi_last
  1963.     cmp.b    #"?",d1
  1964.     bhi.b    .csi_last
  1965.     cmp.l    a1,a3
  1966.     blo.b    .csi_loop
  1967.     bra.b    .dontremove
  1968. .csi_last
  1969.     move.b    -1(a3),d1
  1970.     cmp.b    #"@",d1
  1971.     blo.b    .dontremove
  1972.     cmp.b    #"~",d1
  1973.     bhi.b    .dontremove
  1974.     move.l    a3,a0            ;Remove!
  1975.     bra.b    .nextchar
  1976. .inteCSI
  1977.     cmp.b    d5,d0            ;BS
  1978.     bne.s    .inteBS
  1979.     cmp.l    a2,a4
  1980.     beq.s    .nextchar
  1981.     subq.l    #1,a2            ;remove prev char
  1982.     bra.s    .nextchar
  1983. .inteBS
  1984. .dontremove
  1985.     move.b    d0,(a2)+
  1986. .nextchar
  1987.     cmp.l    a1,a0
  1988.     blo.w    .loop
  1989.     move.l    a2,d0
  1990.     rts
  1991.  
  1992. RemoveCR:
  1993.     tst.l    filememlen
  1994.     beq.b    .exit
  1995.     Message    remcrtext
  1996.     move.l    fileaddr(pc),a0
  1997.     move.l    a0,a1
  1998.     add.l    filelen(pc),a1
  1999.     bsr.b    .RemoveCR
  2000.     move.l    fileaddr(pc),d1
  2001.     sub.l    d1,d0
  2002.     lea    filelen(pc),a0
  2003.     move.l    d0,(a0)
  2004.     Message    screentitle
  2005. .exit
  2006.     moveq    #0,d0
  2007.     rts
  2008. ;in:
  2009. * a0    text
  2010. * a1    textend
  2011. ;ut:
  2012. * d0    nytt textend
  2013. .RemoveCR
  2014.     move.l    a0,a2
  2015.     moveq    #13,d2
  2016. .loop
  2017.     move.b    (a0)+,d0
  2018.     cmp.b    d2,d0            ; ascii 13
  2019.     beq.b    .CR
  2020.     move.b    d0,(a2)+
  2021. .CR
  2022.     cmp.l    a0,a1
  2023.     bhi.b    .loop
  2024.     move.l    a2,d0
  2025.     rts
  2026.  
  2027. *******************************************************************************
  2028. rawkey:
  2029.     cmp.w    #$5f,d3            ;help
  2030.     beq.w    printhelp
  2031.     cmp.w    #$4c,d3
  2032.     beq.W    .crsrup
  2033.     cmp.w    #$4d,d3
  2034.     beq.W    .crsrdown
  2035.     cmp.w    #$4e,d3
  2036.     beq.s    .crsrright
  2037.     cmp.w    #$4f,d3
  2038.     beq.s    .crsrleft
  2039.     cmp.w    #$50,d3
  2040.     blo.b    .notf
  2041.     cmp.w    #$59,d3
  2042.     bls.w    .fkeys
  2043. .notf
  2044.     moveq    #0,d0
  2045.     rts
  2046. .crsrleft
  2047.     move.w    d4,d0
  2048.     and.w    #IEQUALIFIER_LSHIFT!IEQUALIFIER_RSHIFT,d0
  2049.     bne.w    prevpage3
  2050.     move.w    d4,d0
  2051.     and.w    #IEQUALIFIER_LALT!IEQUALIFIER_RALT,d0
  2052.     bne.w    prevbuff
  2053.     bra.w    prevpage
  2054. .crsrright
  2055.     move.w    d4,d0
  2056.     and.w    #IEQUALIFIER_LSHIFT!IEQUALIFIER_RSHIFT,d0
  2057.     bne.w    nextpage3
  2058.     move.w    d4,d0
  2059.     and.w    #IEQUALIFIER_LALT!IEQUALIFIER_RALT,d0
  2060.     bne.w    nextbuff
  2061.     bra.w    nextpage
  2062. .crsrup
  2063.     move.w    d4,d0
  2064.     and.w    #IEQUALIFIER_LSHIFT!IEQUALIFIER_RSHIFT,d0
  2065.     bne.w    prevpage
  2066.     move.w    d4,d0
  2067.     and.w    #IEQUALIFIER_CONTROL,d0
  2068.     bne.w    gotop
  2069.     move.w    d4,d0
  2070.     and.w    #IEQUALIFIER_LALT!IEQUALIFIER_RALT,d0
  2071.     bne.w    prevpage3
  2072.     bra.w    scrolldown1
  2073. .crsrdown
  2074.     move.w    d4,d0
  2075.     and.w    #IEQUALIFIER_LSHIFT!IEQUALIFIER_RSHIFT,d0
  2076.     bne.w    nextpage
  2077.     move.w    d4,d0
  2078.     and.w    #IEQUALIFIER_CONTROL,d0
  2079.     bne.w    gobottom
  2080.     move.w    d4,d0
  2081.     and.w    #IEQUALIFIER_LALT!IEQUALIFIER_RALT,d0
  2082.     bne.w    nextpage3
  2083.     bra.w    scrollup1
  2084. .fkeys
  2085.     sub.w    #$50,d3
  2086.     lsl.w    #2,d3
  2087.     lea    fkeys_lines(pc),a0
  2088.     and.w    #IEQUALIFIER_LSHIFT!IEQUALIFIER_RSHIFT,d4
  2089.     beq.b    .fkeys_goto
  2090.     move.l    linepos(pc),(a0,d3.w)
  2091.     moveq    #0,d0
  2092.     rts
  2093. .fkeys_goto
  2094.     lea    linepos(pc),a1
  2095.     move.l    (a0,d3.w),d0
  2096.     cmp.l    #-1,d0
  2097.     beq.b    .fkeys_exit
  2098.     move.l    d0,(a1)
  2099.     bsr.w    textredraw
  2100. .fkeys_exit
  2101.     moveq    #0,d0
  2102.     rts
  2103. fkeys_lines:
  2104.     dc.l    -1,-1,-1,-1,-1,-1,-1,-1,-1,-1
  2105. fkeys_lines_size    =*-fkeys_lines
  2106. *******************************************************************************
  2107. vanillakey:
  2108.     cmp.w    #$0003,d3
  2109.     beq.w    vctrl_c
  2110.     cmp.w    #$001b,d3
  2111.     beq.w    vesc
  2112.     cmp.w    #"q",d3
  2113.     beq.w    vquit
  2114.  
  2115.     cmp.w    #"?",d3
  2116.     beq.w    vhelp
  2117.     cmp.w    #"h",d3
  2118.     beq.w    vhelp
  2119.  
  2120.     cmp.w    #"w",d3
  2121.     beq.w    vwordwrap
  2122.     cmp.w    #TAB,d3
  2123.     beq.w    mtabsize
  2124.  
  2125.     cmp.w    #"A",d3
  2126.     beq.w    mremansi
  2127.     cmp.w    #"C",d3
  2128.     beq.w    mremcr
  2129.  
  2130.     cmp.w    #"#",d3
  2131.     beq.w    vnummer
  2132.     cmp.w    #"l",d3
  2133.     beq.w    vl
  2134.     cmp.w    #"g",d3
  2135.     beq.w    vg
  2136.     cmp.w    #"%",d3
  2137.     beq.w    vprosenten
  2138.  
  2139.     cmp.w    #"t",d3
  2140.     beq.w    gotop
  2141.     cmp.w    #"<",d3
  2142.     beq.w    gotop
  2143.  
  2144.     cmp.w    #"b",d3
  2145.     beq.w    gobottom
  2146.     cmp.w    #">",d3
  2147.     beq.w    gobottom
  2148.  
  2149.     btst    #IEQUALIFIERB_NUMERICPAD,d4
  2150.     beq.b    .nonumpad
  2151.     cmp.w    #"7",d3
  2152.     beq.w    gotop
  2153.  
  2154.     cmp.w    #"1",d3
  2155.     beq.w    gobottom
  2156.  
  2157.     cmp.w    #"9",d3
  2158.     beq.w    prevpagescroll
  2159.     cmp.w    #"3",d3
  2160.     beq.w    nextpagescroll
  2161.  
  2162.     cmp.w    #"8",d3
  2163.     beq.w    .smoothdown
  2164.  
  2165.     cmp.w    #"2",d3
  2166.     beq.w    .smoothup
  2167.     bra.b    .numpadok
  2168. .nonumpad
  2169.     cmp.w    #"0",d3
  2170.     blo.b    .not1to0
  2171.     cmp.w    #"9",d3
  2172.     bhi.b    .not1to0
  2173.     sub.w    #"0"+1,d3
  2174.     bpl.b    .buffnumok
  2175.     moveq    #9,d3
  2176. .buffnumok
  2177.     moveq    #0,d0
  2178.     move.w    d3,d0
  2179.     bra    multi_change
  2180. .not1to0
  2181. .numpadok
  2182.     cmp.w    #"+",d3
  2183.     beq    nextbuff
  2184.     cmp.w    #"-",d3
  2185.     beq    prevbuff
  2186.  
  2187.     cmp.w    #" ",d3
  2188.     beq.w    nextpage
  2189.     cmp.w    #8,d3            ;bs
  2190.     beq.w    prevpage
  2191.     cmp.w    #13,d3
  2192.     beq.w    scrollup1
  2193.  
  2194.     cmp.w    #"E",d3
  2195.     beq.w    vedittext
  2196.  
  2197.     cmp.w    #"s",d3
  2198.     beq.w    vsearchnocase
  2199.     cmp.w    #".",d3
  2200.     beq.w    vsearchnocase
  2201.     cmp.w    #"S",d3
  2202.     beq.w    vsearchcase
  2203.     cmp.w    #"/",d3
  2204.     beq.w    vsearchcase
  2205.  
  2206.     cmp.w    #"n",d3
  2207.     beq.w    vsearchnext
  2208.     cmp.w    #"p",d3
  2209.     beq.w    searchprev
  2210.  
  2211.     moveq    #0,d0
  2212.     rts
  2213.  
  2214. .smoothup
  2215.     moveq    #0,d1            ;->
  2216.     bra.b    .smooth
  2217. .smoothdown
  2218.     moveq    #1,d1            ;->
  2219. .smooth
  2220.     lea    scrollfart(pc),a0
  2221.     lea    scrolla(pc),a1
  2222.  
  2223.     move.w    d4,d0
  2224.     and.w    #IEQUALIFIER_LSHIFT!IEQUALIFIER_RSHIFT,d0
  2225.     beq.s    .smoothup_noshift
  2226.     move.w    #3,(a0)
  2227.     move.w    #scrolla_crsr,(a1)
  2228.     bra.s    .smoothup_exit
  2229. .smoothup_noshift
  2230.     move.w    d4,d0
  2231.     and.w    #IEQUALIFIER_CONTROL,d0
  2232.     beq.s    .smoothup_nocontrol
  2233.     move.w    #1,(a0)
  2234.     move.w    #scrolla_crsr,(a1)
  2235.     bra.s    .smoothup_exit
  2236. .smoothup_nocontrol
  2237.     move.w    d4,d0
  2238.     and.w    #IEQUALIFIER_LALT!IEQUALIFIER_RALT,d0
  2239.     beq.s    .smoothup_noalt
  2240.     move.w    #4,(a0)
  2241.     move.w    #scrolla_crsr,(a1)
  2242.     bra.s    .smoothup_exit
  2243. .smoothup_noalt
  2244.     move.w    #2,(a0)
  2245.     move.w    #scrolla_crsr,(a1)
  2246. .smoothup_exit
  2247.     tst.l    d1            ;<-
  2248.     beq.b    .smoothup_quit
  2249.     neg.w    (a0)
  2250. .smoothup_quit
  2251.     moveq    #0,d0
  2252.     rts
  2253.  
  2254.  
  2255. vesc:
  2256.     and.w    #IEQUALIFIER_RSHIFT!IEQUALIFIER_LSHIFT,d4
  2257.     bne.b    vquit
  2258.     bsr    mclose
  2259.     moveq    #0,d0
  2260.     rts
  2261. vctrl_c:
  2262. vquit:
  2263.     bsr.w    mquit
  2264.     moveq    #0,d0
  2265.     rts
  2266. vhelp:
  2267.     bsr.w    printhelp
  2268.     moveq    #0,d0
  2269.     rts
  2270. vwordwrap:
  2271.     eor.w    #1,wordwrap
  2272.     bsr.w    updatecheckmarks
  2273.     bsr.w    countlines
  2274.     tst.l    d0
  2275.     bne.b    .exit
  2276.     bsr.w    textredraw
  2277.     moveq    #0,d0
  2278. .exit
  2279.     rts
  2280. vnummer:
  2281. vl:
  2282.  
  2283.     jsr    requestline
  2284.  
  2285.     tst.l    d0
  2286.     bmi.b    .error
  2287.     beq.b    .exit
  2288.  
  2289.     lea    linepos(pc),a0
  2290.     move.l    d1,(a0)
  2291.     bsr.w    textredraw
  2292. .exit
  2293.     moveq    #0,d0
  2294. .error
  2295.     rts
  2296.  
  2297. vprosenten:
  2298. vg:
  2299.     jsr    requestpercent
  2300.  
  2301.     tst.l    d0
  2302.     bmi.b    .error
  2303.     beq.b    .exit
  2304.  
  2305.     move.l    lines(pc),d0
  2306.     sub.l    cheight(pc),d0
  2307.     mulu.w    d1,d0
  2308.     add.l    #50,d0            ;round
  2309.     divu.w    #100,d0
  2310.     and.l    #$0000ffff,d0
  2311.     lea    linepos(pc),a0
  2312.     move.l    d0,(a0)
  2313.  
  2314.     bsr.w    textredraw
  2315. .exit
  2316.     moveq    #0,d0
  2317. .error
  2318.     rts
  2319.  
  2320. vsearchnocase:
  2321.     clr.w    search_case
  2322.     bsr.w    updatecheckmarks
  2323.     bra.w    search
  2324. vsearchcase:
  2325.     move.w    #1,search_case
  2326.     bsr.w    updatecheckmarks
  2327.     bra.w    search
  2328. vsearchnext:
  2329.     bra.w    searchnext
  2330. vedittext:
  2331.     lea.l    filelen(pc),a0
  2332.     tst.l    (a0)
  2333.     beq.B    .nofile
  2334.     base    dos
  2335.     lea    .editor(pc),a0
  2336.     move.l    a0,d1
  2337.     lea    temp,a2
  2338.     move.l    a2,d2
  2339.     move.l    #tempsize,d3
  2340.     moveq    #0,d4
  2341.     call    GetVar
  2342.     tst.l    d0
  2343.     beq.b    .error
  2344.     cmp.l    #-1,d0
  2345.     beq.b    .error
  2346.     add.l    d0,a2
  2347.     move.b    #" ",(a2)+
  2348.     move.b    #'"',(a2)+
  2349.  
  2350.     move.l    a2,d1
  2351.     lea    filereqdir(pc),a1
  2352. .copydir
  2353.     move.b    (a1)+,(a2)+
  2354.     bne.B    .copydir
  2355.     lea    filename(pc),a0        ;d1 already ok
  2356.     move.l    a0,d2
  2357.     lea    tempend-1,a0
  2358.     move.l    a0,d3
  2359.     sub.l    d1,d3            ;size
  2360.     call    AddPart
  2361.     tst.l    d0
  2362.     beq.b    .error
  2363.     lea    temp,a0
  2364.     move.l    a0,d1
  2365. .findnull
  2366.     tst.b    (a0)+
  2367.     bne.b    .findnull
  2368.     move.b    #'"',-1(a0)
  2369.     clr.b    (a0)
  2370.  
  2371.     lea    .tags(pc),a0
  2372.     move.l    a0,d2
  2373.     call    SystemTagList
  2374. .error
  2375.     moveq    #0,d0
  2376.     rts
  2377. .nofile
  2378.     lea    nofileloaded(pc),a1
  2379.     lea    oktext(pc),a2
  2380.     suba.l    a4,a4
  2381.     bsr.w    requester
  2382.     moveq    #0,d0
  2383.     rts
  2384. .editor    dc.b    "editor",0
  2385.     even
  2386. .tags    
  2387.     dc.l    SYS_Asynch,TRUE        ;
  2388.     dc.l    SYS_UserShell,TRUE
  2389.     dc.l    TAG_DONE
  2390. *******************************************************************************
  2391. refreshwindow:
  2392.     base    gt
  2393.     move.l    windowptr(pc),a0
  2394.     call    GT_BeginRefresh
  2395.     move.l    windowptr(pc),a0
  2396.     moveq    #TRUE,d0
  2397.     call    GT_EndRefresh
  2398.     moveq    #0,d0
  2399.     rts
  2400. *******************************************************************************
  2401. handlegadgets:
  2402.     cmp.l    scrollgadget(pc),a2
  2403.     beq.B    .scrollgadget
  2404.     cmp.l    quitgadget(pc),a2
  2405.     beq.B    .quitgadget
  2406.     moveq    #0,d0
  2407.     rts
  2408. .scrollgadget
  2409.     bsr.w    fixlinepos        ;scroll or redraw full page?
  2410.     move.l    cheight(pc),d2
  2411.     subq.l    #3,d2            ;???
  2412.     mulu.w    fonty+2(pc),d2
  2413.     lea    linepos(pc),a0
  2414.     move.l    d3,d0
  2415.     sub.l    (a0),d0
  2416.     muls.w    fonty+2(pc),d0
  2417.     moveq    #1,d1
  2418.     cmp.l    d2,d0
  2419.     bls.w    scrollup_noupdate    ;unsigned
  2420.     neg.l    d2
  2421.     cmp.l    d2,d0
  2422.     bls.s    .notprevline        ;unsigned
  2423.     neg.l    d0
  2424.     bra.w    scrolldown_noupdate
  2425. .notprevline
  2426.     move.l    d3,(a0)            ;code
  2427.     bsr.w    changenum
  2428.     bsr.w    cls
  2429.     move.l    linepos(pc),d0
  2430.     bsr.w    gotoline
  2431.     bsr.w    printpage
  2432.     moveq    #0,d0
  2433.     rts
  2434. .quitgadget
  2435.     bsr    mquit
  2436.     moveq    #0,d0
  2437.     rts
  2438. *******************************************************************************
  2439. handlebuttons:
  2440.     cmp.w    #SELECTDOWN,d3
  2441.     bne.s    .nodown
  2442.     lea    scrolla(pc),a0
  2443.     move.w    #scrolla_mouse,(a0)
  2444. .nodown
  2445.     cmp.w    #SELECTUP,d3
  2446.     bne.s    .noup
  2447.     lea    scrolla(pc),a0        ;stop scrolling
  2448.     clr.w    (a0)
  2449. .noup
  2450.     moveq    #0,d0
  2451.     rts
  2452.  
  2453.  
  2454. *******************************************************************************
  2455. ********************** S U B R U T I N E R ************************************
  2456. *******************************************************************************
  2457.  
  2458. **** prefs
  2459.  
  2460. ;call after new settings has been loaded
  2461. prefs2curr:
  2462.     move.w    setcreateicons(pc),createicons
  2463.     move.w    setwordwrap(pc),wordwrap
  2464.     move.w    setalwaysremansi(pc),alwaysremansi
  2465.     move.w    setalwaysremcr(pc),alwaysremcr
  2466.     move.w    setnofontfake(pc),nofontfake
  2467.     move.w    setlegalprint(pc),legalprint
  2468.  
  2469.     move.w    setsysfont(pc),sysfont
  2470.     move.l    setdisplayid(pc),displayid
  2471.  
  2472.     pushm    d0-a6
  2473.     lea    palette,a1
  2474.     bsr    changepalette
  2475.     popm    d0-a6
  2476.     rts
  2477.  
  2478. ;call before new settins will be loaded
  2479. curr2prefs:
  2480.     move.w    createicons(pc),setcreateicons
  2481.     move.w    wordwrap(pc),setwordwrap
  2482.     move.w    nofontfake(pc),setnofontfake
  2483.     move.w    legalprint(pc),setlegalprint
  2484.     move.w    alwaysremcr(pc),setalwaysremcr
  2485.     move.w    alwaysremansi(pc),setalwaysremansi
  2486.  
  2487.     move.w    sysfont(pc),setsysfont
  2488.     move.l    displayid(pc),setdisplayid
  2489.  
  2490.     pushm    d0-a6
  2491.     lea    palette,a1
  2492.     bsr    getpalette
  2493.     popm    d0-a6
  2494.     rts
  2495.  
  2496. **** buffer
  2497.  
  2498. nextbuff:
  2499.     move.l    bnum(pc),d0
  2500.     cmp.l    bmax(pc),d0
  2501.     bpl.b    .exit
  2502. ;    addq.l    #1-1,d0            ;bnum: 1-...
  2503.     bsr    multi_change
  2504. .exit
  2505.     moveq    #0,d0
  2506.     rts
  2507. prevbuff:
  2508.     move.l    bnum(pc),d0
  2509.     cmp.l    #1,d0
  2510.     beq.b    .exit
  2511.     subq.l    #1+1,d0            ;bnum begins at 1, not 0
  2512.     bsr    multi_change
  2513. .exit
  2514.     moveq    #0,d0
  2515.     rts
  2516.  
  2517. ;level 1
  2518.  
  2519. ;ut:
  2520. * d0    NULL om fel.
  2521. multi_init:
  2522.     pushm    a0
  2523.     lea    bufflist(pc),a0
  2524.     NEWLIST    a0
  2525.     bsr    multi_addbuff
  2526.     lea    thisbuff(pc),a0
  2527.     move.l    d0,(a0)
  2528.     pop    a0
  2529.     rts
  2530. ;in:
  2531. * a0    buffert
  2532. multi_curr2buff:
  2533.     pushm    d0/a0-a2
  2534.     move.l    fileaddr(pc),buff_fileaddr(a0)
  2535.     move.l    filelen(pc),buff_filelen(a0)
  2536.     move.l    filememlen(pc),buff_filememlen(a0)
  2537.     move.l    linepos(pc),buff_linepos(a0)
  2538.     move.l    lines(pc),buff_lines(a0)
  2539.     move.l    linelen(pc),buff_linelen(a0)
  2540.     move.l    linelensize(pc),buff_linelensize(a0)
  2541.  
  2542.     bsr    curr2prefs
  2543.  
  2544.     moveq    #32-1,d0
  2545.     lea    filename(pc),a1
  2546.     lea    buff_filename(a0),a2
  2547. .copyfilename
  2548.     move.b    (a1)+,(a2)+
  2549.     dbf    d0,.copyfilename
  2550.  
  2551.     move.w    #setnamelen-1,d0
  2552.     lea    setname,a1
  2553.     lea    buff_setname(a0),a2
  2554. .copysetname
  2555.     move.b    (a1)+,(a2)+
  2556.     dbf    d0,.copysetname
  2557.  
  2558.     move.w    #settings_len-1,d0
  2559.     lea    settings(pc),a1
  2560.     lea    buff_settings(a0),a2
  2561. .copysettings
  2562.     move.b    (a1)+,(a2)+
  2563.     dbf    d0,.copysettings
  2564.  
  2565.     move.w    #fkeys_lines_size-1,d0
  2566.     lea    fkeys_lines(pc),a1
  2567.     lea    buff_fkeys(a0),a2
  2568. .copyfkeys
  2569.     move.b    (a1)+,(a2)+
  2570.     dbf    d0,.copyfkeys
  2571.  
  2572.     popm    d0/a0-a2
  2573.     rts
  2574.  
  2575. ;in:
  2576. * a0    buffert
  2577. multi_buff2curr:
  2578.     pushm    d0/a0-a2
  2579.     move.l    buff_fileaddr(a0),fileaddr
  2580.     move.l    buff_filelen(a0),filelen
  2581.     move.l    buff_filememlen(a0),filememlen
  2582.     move.l    buff_linepos(a0),linepos
  2583.     move.l    buff_lines(a0),lines
  2584.     move.l    buff_linelen(a0),linelen
  2585.     move.l    buff_linelensize(a0),linelensize
  2586.  
  2587.     moveq    #32-1,d0
  2588.     lea    buff_filename(a0),a1
  2589.     lea    filename(pc),a2
  2590. .copyfilename
  2591.     move.b    (a1)+,(a2)+
  2592.     dbf    d0,.copyfilename
  2593.  
  2594.     move.w    #setnamelen-1,d0
  2595.     lea    buff_setname(a0),a1
  2596.     lea    setname,a2
  2597. .copysetname
  2598.     move.b    (a1)+,(a2)+
  2599.     dbf    d0,.copysetname
  2600.  
  2601.     move.w    #settings_len-1,d0
  2602.     lea    buff_settings(a0),a1
  2603.     lea    settings(pc),a2
  2604. .copysettings
  2605.     move.b    (a1)+,(a2)+
  2606.     dbf    d0,.copysettings
  2607.  
  2608.     move.w    #fkeys_lines_size-1,d0
  2609.     lea    buff_fkeys(a0),a1
  2610.     lea    fkeys_lines(pc),a2
  2611. .copyfkeys
  2612.     move.b    (a1)+,(a2)+
  2613.     dbf    d0,.copyfkeys
  2614.  
  2615.     bsr    prefs2curr
  2616.  
  2617.     popm    d0/a0-a2
  2618.     rts
  2619.  
  2620. multi_clearcurr:
  2621.     clr.l    fileaddr
  2622.     clr.l    filelen
  2623.     clr.l    filememlen
  2624.     clr.l    linepos
  2625.     move.l    #1,lines
  2626.     move.l    #notnull,linelen
  2627.     clr.l    linelensize
  2628.     clr.b    filename
  2629.     rts
  2630.  
  2631. ;in:
  2632. * a0    buffert
  2633. multi_freebuff:
  2634.     pushm    d0-d1/a0-a2/a6
  2635.     move.l    a0,a2
  2636.     base    exec
  2637.  
  2638.  
  2639.     move.l    commessage,d0
  2640.     move.l    d0,a1
  2641.     beq.b    .nomessage
  2642.     move.l    comport,MN_REPLYPORT(a1)
  2643.     move.w    #cm_SIZE,MN_LENGTH(a1)
  2644.     move.w    #cmc_quit,cm_command(a1)
  2645.  
  2646.     move.l    buff_commessageport(a2),d0
  2647.     beq.b    .nomessage
  2648.     move.l    d0,a0
  2649.     move.l    commessage,a1
  2650.     call    PutMsg                ;tell other textread to quit
  2651.  
  2652.     move.l    comport,a0
  2653.     call    WaitPort
  2654. .getallcommsgs
  2655.     move.l    comport,a0
  2656.     call    GetMsg
  2657.     tst.l    d0
  2658.     bne.s    .getallcommsgs
  2659. .nomessage
  2660.     move.l    buff_fileaddr(a2),a1
  2661.     move.l    buff_filememlen(a2),d0
  2662.     beq.B    .nofileinmem
  2663.     call    FreeMem
  2664. .nofileinmem
  2665.     move.l    buff_linelen(a2),a1
  2666.     move.l    buff_linelensize(a2),d0
  2667.     beq.b    .ingetlineminne
  2668.     call    FreeMem
  2669. .ingetlineminne
  2670.     clr.l    buff_fileaddr(a2)
  2671.     clr.l    buff_filelen(a2)
  2672.     clr.l    buff_filememlen(a2)
  2673.     clr.l    buff_linepos(a2)
  2674.     move.l    #1,buff_lines(a2)
  2675.     move.l    #notnull,buff_linelen(a2)
  2676.     clr.l    buff_linelensize(a2)
  2677.     clr.b    buff_filename(a2)
  2678.     popm    d0-d1/a0-a2/a6
  2679.     rts
  2680. multi_freeall:
  2681.     lea    bufflist(pc),a0
  2682.     IFEMPTY    a0,.exit
  2683.     move.l    MLH_HEAD(a0),a0
  2684. .loop
  2685.     tst.l    (a0)
  2686.     beq.b    .exit
  2687.     bsr    multi_freebuff
  2688.     move.l    LN_SUCC(a0),a0
  2689.     bra.b    .loop
  2690. .exit
  2691.     rts
  2692.  
  2693. ;ut:
  2694. * d0    NULL eller buffert.
  2695. multi_addbuff:
  2696.     pushm    d1-d2/a0-a2/a6
  2697.     base    exec
  2698.     move.l    #buff_len,d0
  2699.     move.l    #MEMF_CLEAR!MEMF_ANY,d1
  2700.     call    AllocMem
  2701.     move.l    d0,d2
  2702.     beq.b    .error
  2703.     move.l    d0,a1
  2704.     lea    buff_number(a1),a0
  2705.     move.l    a0,LN_NAME(a1)
  2706.     lea    bufflist(pc),a0
  2707.     call    AddTail
  2708.     move.l    d2,a0
  2709.     clr.l    buff_fileaddr(a0)
  2710.     clr.l    buff_filelen(a0)
  2711.     clr.l    buff_filememlen(a0)
  2712.     clr.l    buff_linepos(a0)
  2713.     move.l    #1,buff_lines(a0)
  2714.     move.l    #notnull,buff_linelen(a0)
  2715.     clr.l    buff_linelensize(a0)
  2716.     clr.b    buff_filename(a0)
  2717.  
  2718. ;default: same settings and -name
  2719.  
  2720.     move.w    #setnamelen-1,d0
  2721.     lea    setname,a1
  2722.     lea    buff_setname(a0),a2
  2723. .copysetname
  2724.     move.b    (a1)+,(a2)+
  2725.     dbf    d0,.copysetname
  2726.  
  2727.     move.w    #settings_len-1,d0
  2728.     lea    settings(pc),a1
  2729.     lea    buff_settings(a0),a2
  2730. .copysettings
  2731.     move.b    (a1)+,(a2)+
  2732.     dbf    d0,.copysettings
  2733.  
  2734.     move.l    a0,d0
  2735.     popm    d1-d2/a0-a2/a6
  2736.     rts
  2737. .error
  2738.     popm    d1-d2/a0-a2/a6
  2739.     moveq    #0,d0
  2740.     rts
  2741.  
  2742. ;in:
  2743. * a0    buffert att ta bort
  2744. multi_rembuff:
  2745.     pushm    d0-d2/a0-a1/a6
  2746.     base    exec
  2747.     move.l    a0,d2
  2748.     move.l    a0,a1
  2749.     call    Remove
  2750.     move.l    d2,a1
  2751.     move.l    #buff_len,d0
  2752.     call    FreeMem
  2753.     popm    d0-d2/a0-a1/a6
  2754.     rts
  2755.  
  2756. multi_remall:
  2757.     pushm    d0-d1/a0-a1/a6
  2758.     base    exec
  2759. .loop
  2760.     lea    bufflist(pc),a0
  2761.     call    RemTail
  2762.     tst.l    d0
  2763.     beq.b    .exit
  2764.     move.l    d0,a1
  2765.     move.l    #buff_len,d0
  2766.     call    FreeMem
  2767.     bra.b    .loop
  2768. .exit
  2769.     popm    d0-d1/a0-a1/a6
  2770.     rts
  2771. ;in:
  2772. * a0    buffert
  2773. ;ut:
  2774. * d0    NULL om ok.
  2775. multi_usebuff:
  2776.     pushm    d1-a6
  2777.  
  2778.     move.w    sysfont(pc),d1
  2779.     move.l    displayid(pc),d2
  2780.  
  2781.     bsr    multi_buff2curr
  2782. ; d1,d2..
  2783.     bsr    changeenv
  2784.  
  2785.     popm    d1-a6
  2786.     rts
  2787.  
  2788.  
  2789. ;level 2 (thisbuff must be valid for all but multi_quit)
  2790.  
  2791. ;ut:
  2792. * d0    NULL eller felkod
  2793. multi_new_nochange:
  2794.     pushm    a0
  2795.     move.l    thisbuff(pc),a0
  2796.     bsr    multi_curr2buff
  2797.     bsr    multi_addbuff
  2798.     lea    thisbuff(pc),a0
  2799.     move.l    d0,(a0)
  2800.     beq.b    .error
  2801.     moveq    #0,d0
  2802.     popm    a0
  2803.     rts
  2804. .error
  2805.     moveq    #err_nomem,d0
  2806.     popm    a0
  2807.     rts
  2808. ;ut:
  2809. * d0    NULL eller felkod
  2810. multi_new:
  2811.     pushm    a0
  2812.     move.l    thisbuff(pc),a0
  2813.     bsr    multi_curr2buff
  2814.     bsr    multi_addbuff
  2815.     lea    thisbuff(pc),a0
  2816.     move.l    d0,(a0)
  2817.     beq.b    .error
  2818.     move.l    d0,a0
  2819.     bsr    multi_usebuff
  2820.     popm    a0
  2821.     rts
  2822. .error
  2823.     moveq    #err_nomem,d0
  2824.     popm    a0
  2825.     rts
  2826.  
  2827. ;ut:
  2828. * d0    NULL eller felkod
  2829. multi_close:
  2830.     pushm    a0/a1
  2831.     lea    bufflist(pc),a0
  2832.     move.l    MLH_HEAD(a0),d0
  2833.     cmp.l    MLH_TAILPRED(a0),d0
  2834.     beq.b    .exit            ;don't close last one!
  2835.     move.l    thisbuff(pc),a0
  2836.     move.l    LN_SUCC(a0),a1
  2837.     tst.l    (a1)
  2838.     bne.b    .ok
  2839.     move.l    LN_PRED(a0),a1
  2840. .ok
  2841.     bsr    multi_curr2buff
  2842.     bsr    multi_freebuff
  2843.     bsr    multi_rembuff
  2844.     move.l    a1,a0
  2845.     lea    thisbuff(pc),a1
  2846.     move.l    a0,(a1)
  2847.     bsr    multi_usebuff
  2848. .exit
  2849.     popm    a0/a1
  2850.     rts
  2851.  
  2852. ;in:
  2853. * d0    buffer #
  2854. ;ut:
  2855. * d0    NULL eller felkod
  2856. multi_change:
  2857.     move.l    thisbuff(pc),a0
  2858.     bsr    multi_curr2buff
  2859.     lea    bufflist(pc),a0
  2860. .stepdown
  2861.     TSTNODE    a0,a0
  2862.     beq.b    .error
  2863.     dbf    d0,.stepdown
  2864.     lea    thisbuff(pc),a1
  2865.     move.l    a0,(a1)
  2866.     bsr    multi_usebuff
  2867.     rts
  2868. .error
  2869.     moveq    #0,d0
  2870.     rts
  2871.  
  2872. multi_quit:
  2873.     pushm    d0/a0
  2874.     move.l    thisbuff(pc),a0
  2875.     move.l    a0,d0
  2876.     beq.b    .nocurr
  2877.     bsr    multi_curr2buff
  2878. .nocurr
  2879.     bsr    multi_freeall
  2880.     bsr    multi_remall
  2881.     bsr    multi_clearcurr
  2882.     clr.l    thisbuff
  2883.     popm    d0/a0
  2884.     rts
  2885.  
  2886. ;FIXIT! Countlines may have to be done on some buffers!
  2887. multi_prefs2all:
  2888.     pushm    d0/a0
  2889.  
  2890.     lea    bufflist(pc),a0
  2891.     IFEMPTY    a0,.exit
  2892.     move.l    MLH_HEAD(a0),a0
  2893. .loop
  2894.     tst.l    (a0)
  2895.     beq.b    .exit
  2896.  
  2897.     bsr.b    .copyit
  2898.  
  2899.     move.l    LN_SUCC(a0),a0
  2900.     bra.b    .loop
  2901. .exit
  2902.     popm    d0/a0
  2903.     rts
  2904.  
  2905. .copyit
  2906.     pushm    d0/a1-a2
  2907.     move.w    #prefs2all_len-1,d0
  2908.     lea    prefs2all_start(pc),a1
  2909.     lea    buff_settings+prefs2all_offset(a0),a2
  2910. .copysettings
  2911.     move.b    (a1)+,(a2)+
  2912.     dbf    d0,.copysettings
  2913.     popm    d0/a1-a2
  2914.     rts
  2915.  
  2916. * laddar in filerna i de resterande bufferterna
  2917. ;in:
  2918. * a5    pek till nod i bufflist
  2919. ;ut:
  2920. * d0    0 om ok
  2921. multi_loadrest:
  2922.     pushm    d1-a6
  2923.     bsr    changevideomode
  2924.     tst.l    d0
  2925.     bne.b    .exit
  2926.     lea    tabbar,a0
  2927.     bsr    fixatabbar
  2928.     bra.b    .changed
  2929.  
  2930. .loop
  2931.     tst.l    (a5)
  2932.     beq.b    .listisempty
  2933.  
  2934.     move.l    thisbuff(pc),a0
  2935.     bsr    multi_curr2buff
  2936.     move.l    a5,a0
  2937.     lea    thisbuff(pc),a1
  2938.     move.l    a0,(a1)
  2939.     bsr    multi_usebuff
  2940.     tst.l    d0
  2941.     bne.b    .exit
  2942. .changed
  2943.     lea    filename(pc),a1
  2944.     tst.b    (a1)
  2945.     beq.b    .openreq
  2946.     move.l    #tempsize,d0
  2947.     lea    filereqdir(pc),a0
  2948.     lea    filename(pc),a1
  2949.     lea    temp,a2
  2950.     bsr    pathnfiletobuff
  2951.     move.l    #temp,d0
  2952.     bsr    openfile
  2953.     tst.l    d0
  2954.     beq.b    .nextbuffer
  2955. .openreq
  2956.     pushm    d1-a6
  2957.     bsr    mopen
  2958.     popm    d1-a6
  2959. .nextbuffer
  2960.     move.l    LN_SUCC(a5),a5
  2961.     bra.b    .loop
  2962. .listisempty
  2963.     moveq    #0,d0
  2964. .exit
  2965.     lea    pipeused(pc),a0
  2966.     tst.b    (a0)
  2967.     bne.b    .nopipe
  2968.  
  2969.     pushm    d0
  2970.     base    dos
  2971.     lea    pipename(pc),a0
  2972.     move.l    a0,d1
  2973.     call    DeleteFile
  2974.     popm    d0
  2975. .nopipe
  2976.  
  2977.     popm    d1-a6
  2978.     rts
  2979. thisbuff:
  2980.     dc.l    0
  2981. bufflist:
  2982.     ds.b    MLH_SIZE        ;minimal list header
  2983.  
  2984. **** window locking
  2985.  
  2986. ;    *** nestla inte! ***
  2987. lockwindow:
  2988.     movem.l    d0-d1/a0-a2/a6,-(sp)
  2989.     base    intui
  2990.     lea    lockwinreq,a2
  2991.     move.l    a2,a0
  2992.     call    InitRequester
  2993.     move.l    a2,a0
  2994.     move.l    windowptr(pc),d0
  2995.     beq.b    .nowin
  2996.     move.l    d0,a1
  2997.     call    Request
  2998.     lea    lockwinreqsuccess(pc),a0
  2999.     move.l    d0,(a0)
  3000.     cmp.w    #39,LIB_VERSION(a6)
  3001.     blo.s    .no39
  3002.     move.l    windowptr(pc),a0
  3003.     lea    .tags(pc),a1
  3004.     call    SetWindowPointerA
  3005. .no39
  3006. .nowin
  3007.     movem.l    (sp)+,d0-d1/a0-a2/a6
  3008.     rts
  3009. .tags
  3010.     dc.l    WA_BusyPointer,TRUE
  3011.     dc.l    TAG_DONE
  3012. unlockwindow:
  3013.     movem.l    d0-d1/a0-a1/a6,-(sp)
  3014.     tst.l    lockwinreqsuccess
  3015.     beq.s    .nolock
  3016.     lea    lockwinreqsuccess(pc),a0
  3017.     clr.l    (a0)
  3018.     base    intui
  3019.     lea    lockwinreq,a0
  3020.     move.l    windowptr(pc),d0
  3021.     beq.b    .nowin
  3022.     move.l    d0,a1
  3023.     call    EndRequest
  3024.     cmp.w    #39,LIB_VERSION(a6)
  3025.     blo.s    .no39
  3026.     move.l    windowptr(pc),a0
  3027.     lea    .tags(pc),a1
  3028.     call    SetWindowPointerA
  3029. .no39
  3030. .nolock
  3031. .nowin
  3032.     movem.l    (sp)+,d0-d1/a0-a1/a6
  3033.     rts
  3034. .tags
  3035.     dc.l    WA_BusyPointer,FALSE
  3036.     dc.l    TAG_DONE
  3037. lockwinreqsuccess:
  3038.     dc.l    0
  3039.  
  3040. **** argument parsing
  3041.  
  3042. getargs:
  3043.     lea    boolcli(pc),a0
  3044.     tst.l    (a0)
  3045.     bne.w    ga_cli
  3046. ga_workbench:
  3047.     move.l    argset(pc),a0        ;default prefs
  3048.     bsr.w    loadsettings
  3049.     bsr    prefs2curr
  3050.  
  3051.     move.l    wbmessage(pc),a0
  3052.     move.l    sm_NumArgs(a0),d1
  3053.     move.l    sm_ArgList(a0),a2
  3054.  
  3055. ;in:
  3056. * d1    NumArgs
  3057. * a2    ArgList
  3058. parsewbarg:
  3059.     moveq    #TRUE,d2
  3060.     bsr.b    readargsfromicon
  3061.  
  3062.     add.w    #wa_SIZEOF,a2        ;first project
  3063.     subq.l    #1,d1
  3064. ;in:
  3065. * d1    NumArgs
  3066. * a2    ArgList
  3067. parsewbarg_proj:
  3068.     subq.w    #1,d1
  3069.     bmi.B    .noproject
  3070. .projectloop
  3071.     move.l    wa_Name(a2),a0
  3072.     tst.b    (a0)
  3073.     beq.b    .nofile
  3074.     moveq    #FALSE,d2
  3075.     bsr.b    readargsfromicon
  3076.     bra.b    .nodir
  3077. .nofile
  3078.     bsr.b    .wasdiricon
  3079. .nodir
  3080.     tst.l    d1            ;last file?
  3081.     beq.b    .noproject
  3082.     tst.l    d0            ;was it prefs?
  3083.     bne.b    .nextproject
  3084.     bsr    multi_new_nochange
  3085.     tst.l    d0
  3086.     bne.b    .noproject
  3087. .nextproject
  3088.     add.w    #wa_SIZEOF,a2        ;next project
  3089.     dbf    d1,.projectloop
  3090. .noproject
  3091.     move.l    thisbuff(pc),a0
  3092.     bsr    multi_curr2buff        ;save last buffer
  3093.  
  3094.     moveq    #0,d0
  3095.     rts
  3096. .wasdiricon
  3097.     pushm    d1-d3/a0-a3
  3098.     base    dos
  3099.     move.l    wa_Lock(a2),d1
  3100.     lea    filereqdir(pc),a0
  3101.     move.l    a0,d2
  3102.     move.l    #256,d3
  3103.     call    NameFromLock
  3104.     clr.b    filename
  3105.     moveq    #FALSE,d0        ;no prefs file
  3106.     popm    d1-d3/a0-a3
  3107.     rts
  3108.  
  3109. ;in:
  3110. * a2    pek till WBArg   (eller: dc.l lock : dc.l name)
  3111. * d2    TRUE=denna fil ska _inte_ laddas in (rör inte filename, filereqpath)
  3112. ;ut:
  3113. * d0    TRUE om filen var en prefsfil
  3114. readargsfromicon:
  3115.     pushm    d1-a6
  3116.  
  3117.     moveq    #FALSE,d5
  3118.  
  3119.     bsr.w    .loadicon
  3120.     tst.l    d0
  3121.     beq.w    .filewithouticon
  3122.     base    icon
  3123.     move.l    d0,a0
  3124.     move.l    do_ToolTypes(a0),a2
  3125.  
  3126.     move.l    a2,a0
  3127.     lea    .filetype(pc),a1
  3128.     call    FindToolType
  3129.     tst.l    d0
  3130.     beq.b    .nofiletype
  3131.     move.l    d0,a0
  3132.     lea    .prefs(pc),a1
  3133.     call    MatchToolValue
  3134.     tst.l    d0
  3135.     beq.b    .notprefs
  3136.  
  3137.     moveq    #TRUE,d5
  3138.     lea    argprojectname,a0
  3139.     bsr.w    loadsettings        ;load prefs file first
  3140.     bsr    prefs2curr
  3141.     bra.b    .skipload
  3142. .notprefs
  3143. .nofiletype
  3144.     move.l    a2,a0
  3145.     lea    .settings(pc),a1
  3146.     call    FindToolType
  3147.     tst.l    d0
  3148.     beq.b    .nosettings
  3149.     move.l    d0,a0
  3150.  
  3151.     bsr.w    loadsettings        ;load prefs file first
  3152.     bsr    prefs2curr
  3153. .nosettings
  3154. ;om man kommer hit var filen i fråga inte nån prefsfil, dvs denna ska vi
  3155. ;ladda in
  3156.     tst.l    d2
  3157.     bne.b    .skipload
  3158.     move.l    #argprojectname,d2
  3159.     moveq    #0,d0            ;wb has always full path!
  3160.     bsr    splitfilepath
  3161. .skipload
  3162.  
  3163.     move.l    a2,a0
  3164.     lea    .new(pc),a1
  3165.     call    FindToolType
  3166.     tst.l    d0
  3167.     beq.b    .nonew
  3168.     lea    argnew(pc),a0
  3169.     move.l    #1,(a0)
  3170. .nonew
  3171.     move.l    a2,a0
  3172.     lea    .tabs(pc),a1
  3173.     call    FindToolType
  3174.     tst.l    d0
  3175.     beq.b    .notabs
  3176.     move.l    d0,d1
  3177.     lea    .tabsize(pc),a0
  3178.     move.l    a0,d2
  3179.     base    dos
  3180.     call    StrToLong
  3181.     cmp.l    #-1,d0
  3182.     beq.b    .notabs
  3183.     lea    tabsize(pc),a0
  3184.     lea    .tabsize(pc),a1
  3185.     move.l    (a1),(a0)
  3186. .notabs
  3187.     base    icon
  3188.     move.l    a2,a0
  3189.     lea    .unit(pc),a1
  3190.     call    FindToolType
  3191.     tst.l    d0
  3192.     beq.b    .nounit
  3193.     move.l    d0,d1
  3194.     lea    .unittmp(pc),a0
  3195.     move.l    a0,d2
  3196.     base    dos
  3197.     call    StrToLong
  3198.     cmp.l    #-1,d0
  3199.     beq.b    .nounit
  3200.     lea    unit(pc),a0
  3201.     lea    .unittmp(pc),a1
  3202.     move.l    a1,(a0)
  3203. .nounit
  3204. .freediskobj
  3205.     base    icon
  3206.     move.l    wbdiskobj(pc),d0
  3207.     beq.b    .noicon
  3208.     move.l    d0,a0
  3209.     call    FreeDiskObject
  3210.     lea    wbdiskobj(pc),a0
  3211.     clr.l    (a0)
  3212. .noicon
  3213.     move.l    d5,d0
  3214.     popm    d1-a6
  3215.     rts
  3216. .filewithouticon
  3217.     tst.l    d2
  3218.     bne.b    .freediskobj
  3219.     move.l    #argprojectname,d2
  3220.     moveq    #0,d0            ;wb has always full path!
  3221.     bsr    splitfilepath
  3222.     bra.b    .freediskobj
  3223.  
  3224. .tabsize    dc.l    0
  3225. .unittmp        dc.l    0
  3226. ;in:
  3227. * a2    pek till WBArg   (eller: dc.l lock : dc.l name)
  3228. ;ut:
  3229. * d0    pek till diskobj eller 0 om fel
  3230. .loadicon
  3231.     pushm    d1-d3/a0
  3232.     base    dos
  3233.     move.l    (a2),d1
  3234.     move.l    #argprojectname,d2
  3235.     move.l    #256,d3
  3236.     call    NameFromLock
  3237.     tst.l    d0
  3238.     beq.b    .li_error
  3239.     move.l    d2,d1
  3240.     move.l    4(a2),d2
  3241.     move.l    #256,d3
  3242.     call    AddPart
  3243.     tst.l    d0
  3244.     beq.b    .li_error
  3245.     base    icon
  3246.     lea    argprojectname,a0
  3247.     call    GetDiskObject
  3248.     lea    wbdiskobj(pc),a0
  3249.     move.l    d0,(a0)
  3250. .li_error
  3251.     popm    d1-d3/a0
  3252.     rts
  3253. .filetype    dc.b    "FILETYPE",0
  3254. .prefs        dc.b    "PREFS",0
  3255. .tabs        dc.b    "TABS",0
  3256. .new        dc.b    "NEW",0
  3257. .unit        dc.b    "UNIT",0
  3258. .settings    dc.b    "SETTINGS",0
  3259.     even
  3260. ga_cli:
  3261.     base    dos
  3262.     lea    ga_template(pc),a0
  3263.     move.l    a0,d1
  3264.     lea    args(pc),a0
  3265.     move.l    a0,d2
  3266.     moveq    #0,d3
  3267.     call    ReadArgs
  3268.     move.l    d0,rastruct
  3269.     bne.b    .ok
  3270. .show
  3271.     lea    ga_usage(pc),a0
  3272.     move.l    a0,d1
  3273.     call    PutStr
  3274.     moveq    #err_exitnow,d0
  3275.     rts
  3276. .ok
  3277.     move.l    argset(pc),a0
  3278.     bsr.w    loadsettings        ;load prefs file first
  3279.     bsr    prefs2curr
  3280.  
  3281.     move.l    argunit(pc),a0
  3282.     lea    unit(pc),a1
  3283.     move.l    (a0),(a1)
  3284.  
  3285.     move.l    argtab(pc),a0
  3286.     lea    tabsize(pc),a1
  3287.     move.l    (a0),(a1)
  3288.  
  3289.     base    dos
  3290.     call    Input
  3291.     move.l    d0,d4
  3292.     beq.w    .noinputfile
  3293.     move.l    d4,d1
  3294.     call    IsInteractive
  3295.     tst.l    d0            ;Interactive (= no file redirection)?
  3296.     bne.w    .noinputfile        ;Yes, skip
  3297.  
  3298.     move.l    d4,d1
  3299.     move.l    #temp,d2
  3300.     move.l    #tempsize,d3
  3301.     call    NameFromFH
  3302.     tst.l    d0
  3303.     beq.b    .pipe
  3304.  
  3305. ;Standard redirection: Filename & size known!
  3306.  
  3307.     moveq    #0,d0
  3308.     move.l    #temp,d2
  3309.     bsr    splitfilepath
  3310.     bra.w    parsefilenamearray\.exit
  3311.  
  3312. ;Pipe: Unknown name, unknown size :-(
  3313.  
  3314. .pipe
  3315.     base    util
  3316.     cmp.w    #39,LIB_VERSION(a6)
  3317.     blo.s    .nov39
  3318.     call    GetUniqueID
  3319.     bra.b    .uniqueidok
  3320. .nov39
  3321.     move.l    thistask(pc),d0
  3322. .uniqueidok
  3323.     bsr    numdec
  3324.     move.l    d0,a0
  3325.     lea    pipenamenum(pc),a1
  3326. .copynum    
  3327.     move.b    (a0)+,(a1)+
  3328.     bne.b    .copynum
  3329.  
  3330.     base    exec
  3331.     move.l    #1024,d0
  3332.     moveq    #MEMF_ANY,d1
  3333.     call    AllocVec
  3334.     move.l    d0,d6
  3335.     beq.w    .nomem
  3336.     base    dos
  3337.     lea    pipename(pc),a0
  3338.     move.l    a0,d1
  3339.     move.l    #MODE_NEWFILE,d2
  3340.     call    Open
  3341.     move.l    d0,d5
  3342.     beq.b    .nooutputfile
  3343.  
  3344.     move.l    d4,d1
  3345.     move.l    d6,d2
  3346.     move.l    #1024,d3
  3347.     call    Read
  3348.     move.l    d0,d3
  3349.     beq.b    .error            ;EOF on first read => run (for example)
  3350.     addq.l    #1,d0
  3351.     beq.b    .error
  3352.  
  3353. .copyfile
  3354.     move.l    d5,d1
  3355.     move.l    d6,d2
  3356.     call    Write
  3357.     addq.l    #1,d0
  3358.     beq.b    .error
  3359.  
  3360.     move.l    d4,d1
  3361.     move.l    d6,d2
  3362.     move.l    #1024,d3
  3363.     call    Read
  3364.     move.l    d0,d3
  3365.     beq.b    .eof
  3366.     addq.l    #1,d0
  3367.     bne.b    .copyfile
  3368.  
  3369. .eof
  3370.  
  3371.     lea    argnames(pc),a1
  3372.     lea    pipeargnames(pc),a0
  3373.     move.l    a0,(a1)
  3374. .error
  3375.     lea    pipeused(pc),a0        ;mark file to be deleted
  3376.     clr.b    (a0)
  3377.  
  3378.     base    dos
  3379.     move.l    d5,d1
  3380.     call    Close
  3381.  
  3382. .nooutputfile
  3383.     base    exec
  3384.     move.l    d6,a1
  3385.     call    FreeVec
  3386. .nomem
  3387.  
  3388.  
  3389. .noinputfile
  3390.  
  3391.  
  3392. ; gå igenom alla filnamn som angavs, skapa en ny buffer för var och en
  3393. ; av dom (utom den första).
  3394.  
  3395.     move.l    argnames(pc),a2
  3396.     moveq    #0,d0            ;currentdir is ok
  3397.  
  3398. ;in:
  3399. * d0    currentdir (string) eller 0
  3400. * a2    array med pek till filnamn/dirs
  3401.  
  3402. parsefilenamearray:
  3403.     move.l    d0,.currentdir
  3404.     cmp.l    #0,a2
  3405.     beq.b    .exit
  3406. .copynextname
  3407.     move.l    (a2)+,d2
  3408.     beq.b    .exit
  3409.  
  3410.     move.l    .currentdir(pc),d0
  3411.     bsr    splitfilepath
  3412.  
  3413.     tst.l    (a2)
  3414.     beq.b    .exit
  3415.     bsr    multi_new_nochange
  3416.     tst.l    d0
  3417.     beq.b    .copynextname
  3418. .exit
  3419.     move.l    thisbuff(pc),a0
  3420.     bsr    multi_curr2buff        ;save last buffer
  3421.     moveq    #0,d0
  3422.     rts
  3423. .currentdir
  3424.     dc.l    0
  3425. ga_template:
  3426.     dc.b    "FILES/M,TABS/K/N,UNIT/K/N,SETTINGS/K,NEW/S",0
  3427. ;FIXIT! Localize it!
  3428. ga_usage:
  3429.     dc.b    27,"[1mTextread "
  3430.     releasestr
  3431.     dc.b    27,"[22m ©1992-1995 Martin Blom.",10
  3432.     dc.b    "Usage: Textread [[FILES] <files|dirs>] [TABS <n>] [UNIT <n>]",10
  3433.     dc.b    "                [SETTINGS <name>] [NEW]",10,0
  3434.     even
  3435. ;FIXIT! kommentarer => engelska
  3436. args:
  3437. argnames:    dc.l    null        ;pek till lista med filnamn
  3438. argtab:        dc.l    tabsize        ;pek till lw med tab
  3439. argunit:    dc.l    null        ;pek till lw med unit
  3440. argset:        dc.l    defsetname    ;pek till settingsnamn
  3441. argnew:        dc.l    0        ;0 eller inte 0
  3442. * ^^^ fylls i av readargs
  3443. argdir:        dc.l    null        ;pek till dirnamn
  3444.  
  3445. boolcli:    dc.l    1
  3446. wbmessage:    dc.l    0
  3447. wbdiskobj:    dc.l    0
  3448. rastruct:    dc.l    0
  3449.  
  3450. pipeargnames:    dc.l    pipename,0
  3451. pipeused:    dc.b    1        ;0=pipe, 1=no pipe
  3452. pipename:    dc.b    "T:TextreadPipe"
  3453. pipenamenum:    dc.b    "0000000000",0
  3454.  
  3455. **** file names
  3456.  
  3457. ;in:
  3458. * d0    currentdir (lock) eller 0
  3459. * d2    filnamn med path
  3460. ;ut:
  3461. * filename & filereqdir ifyllt med inga relativa sökvägar kvar
  3462. splitfilepath:
  3463.     pushm    d0-d3/a0-a1/a6
  3464.     base    dos
  3465.     move.l    d2,.filename
  3466.     clr.l    .currentdir
  3467.     move.l    d0,d1
  3468.     beq.b    .nocurrdir
  3469.     call    CurrentDir
  3470.     move.l    d0,.currentdir
  3471. .nocurrdir
  3472.     move.l    .filename(pc),d1
  3473.     moveq    #ACCESS_READ,d2
  3474.     call    Lock                ;för att expandera pathen
  3475.     move.l    d0,.lock
  3476.     bne.b    .lockedfile
  3477.     move.l    .filename(pc),d1
  3478.     bra.b    .splitit            ;ta det namnet som skrevs!
  3479. .lockedfile
  3480.     clr.l    fib+fib_DirEntryType
  3481.     move.l    .lock,d1
  3482.     move.l    #fib,d2
  3483.     call    Examine                ;skit i resultatet
  3484.  
  3485.     move.l    .lock(pc),d1
  3486.     move.l    #temp,d2
  3487.     move.l    #tempsize,d3
  3488.     call    NameFromLock
  3489.     move.l    .lock(pc),d1
  3490.     call    UnLock
  3491.     tst.l    fib+fib_DirEntryType
  3492.     bmi.b    .wasfile
  3493.     clr.b    filename        
  3494.     move.l    .filename(pc),a0
  3495.     bra.b    .copydir
  3496. .wasfile
  3497.     move.l    #temp,d1
  3498. .splitit
  3499.     move.l    d1,d2        ;->
  3500.     call    FilePart
  3501.     move.l    d0,a0
  3502.     lea    filename(pc),a1
  3503.     moveq    #31,d0
  3504. .copynameloop
  3505.     move.b    (a0)+,(a1)+
  3506.     dbeq    d0,.copynameloop
  3507.  
  3508.     move.l    d2,d1        ;<-
  3509.     call    PathPart
  3510.     move.l    d0,a0
  3511.     clr.b    (a0)        ;klipp bort filnamnet
  3512.     move.l    d2,a0        ;<-
  3513. .copydir
  3514.     lea    filereqdir(pc),a1
  3515.     move.w    #255,d0
  3516. .copydirloop
  3517.     move.b    (a0)+,(a1)+
  3518.     dbeq    d0,.copydirloop
  3519. .exit
  3520.     move.l    .currentdir,d1
  3521.     beq.b    .nocurrdir2
  3522.     call    CurrentDir    ;återställ!
  3523. .nocurrdir2
  3524.     popm    d0-d3/a0-a1/a6
  3525.     rts
  3526. .lock    dc.l    0
  3527. .currentdir
  3528.     dc.l    0
  3529. .filename
  3530.     dc.l    0
  3531. ;in:
  3532. * d0    buffertlängd
  3533. * a0    path
  3534. * a1    filnamn
  3535. * a2    buffert
  3536. pathnfiletobuff:
  3537.     base    dos
  3538.     move.l    a2,d1
  3539.     move.l    a1,d2
  3540.     move.l    d0,d3
  3541.     subq.w    #1,d0
  3542. .copydir
  3543.     move.b    (a0)+,(a2)+
  3544.     dbf    d0,.copydir
  3545.     call    AddPart
  3546.     tst.l    d0
  3547.     beq.b    .exit
  3548.     moveq    #0,d0
  3549.     rts
  3550. .exit
  3551.     moveq    #-1,d0
  3552.     rts
  3553.  
  3554. **** buffer movements
  3555.  
  3556. ;in:
  3557. * d0    gå till rad (0-?)
  3558. ;ut:
  3559. * d0    rader att printa-1
  3560. * a0    adress till rad
  3561. gotoline:
  3562.     movem.l    d1-d2/a1,-(sp)
  3563.     move.l    .thisline(pc),d1
  3564.     move.l    d1,d2
  3565.     lea    .thisline(pc),a0
  3566.     move.l    d0,(a0)
  3567.     move.l    fileaddr(pc),a0
  3568.     move.l    linelen(pc),a1
  3569.     sub.l    d0,d1
  3570.     bmi.b    .minus
  3571.     cmp.l    d0,d1
  3572.     bhs.b    .beginning
  3573.  
  3574.     add.l    d2,a1            ;<-- curr
  3575.     move.l    .thisaddr(pc),a0
  3576.     move.l    d1,d0
  3577.     subq.l    #1,d0
  3578.     bmi.b    .ok
  3579.     moveq    #0,d1
  3580. .loop1
  3581.     move.b    -(a1),d1
  3582.     addq.w    #1,d1
  3583.     sub.w    d1,a0
  3584.     dbf    d0,.loop1
  3585.     bra.b    .ok
  3586. .minus
  3587.     neg.l    d1
  3588.     cmp.l    d0,d1
  3589.     bhs.b    .beginning
  3590.     add.l    d2,a1            ;curr -->
  3591.     move.l    .thisaddr(pc),a0
  3592.     move.l    d1,d0
  3593. .beginning
  3594.     subq.l    #1,d0
  3595.     bmi.b    .ok
  3596.     moveq    #0,d1
  3597. .loop
  3598.     move.b    (a1)+,d1
  3599.     addq.w    #1,d1
  3600.     add.w    d1,a0
  3601.     dbf    d0,.loop
  3602. .ok
  3603.     lea    .thisaddr(pc),a1
  3604.     move.l    a0,(a1)
  3605.     move.l    lines(pc),d0
  3606.     sub.l    .thisline(pc),d0
  3607.     cmp.l    cheight(pc),d0
  3608.     ble.b    .ok2
  3609.     move.l    cheight(pc),d0
  3610. .ok2
  3611.     movem.l    (sp)+,d1-d2/a1
  3612.     rts
  3613. .thisaddr    dc.l    0
  3614. .thisline    dc.l    1
  3615.  
  3616.  
  3617. ;in:
  3618. * a0    adress
  3619. ;ut:
  3620. * d0    rad som a0 var på
  3621. getline:
  3622.     pushm    d1/a0-a2
  3623.     move.l    fileaddr(pc),a1
  3624.     move.l    linelen(pc),a2
  3625.     moveq    #0,d0
  3626. .loop
  3627.     cmp.l    a0,a1
  3628.     bhi.b    .ok        ;om passerat
  3629.     move.b    (a2)+,d1
  3630.     addq.w    #1,d1
  3631.     add.w    d1,a1
  3632.     addq.l    #1,d0
  3633.     bra.b    .loop
  3634. .ok
  3635.     popm    d1/a0-a2
  3636.     rts
  3637.  
  3638. gotop:
  3639.     lea    linepos(pc),a0
  3640.     tst.l    (a0)
  3641.     beq.b    .exit
  3642.     clr.l    (a0)
  3643.     bra.w    textredraw
  3644. .exit
  3645.     rts
  3646. gobottom:
  3647.     lea    linepos(pc),a0
  3648.     move.l    lines(pc),d0
  3649.     sub.l    cheight(pc),d0
  3650.     bpl.b    .ok
  3651.     moveq    #0,d0
  3652. .ok
  3653.     cmp.l    (a0),d0
  3654.     beq.b    .exit
  3655.     move.l    d0,(a0)
  3656.     bra.w    textredraw
  3657. .exit
  3658.     rts
  3659. prevpage:
  3660.     lea    linepos(pc),a0
  3661.     move.l    (a0),d0
  3662.     bne.b    .ok1        ;redan 0 ?
  3663.     moveq    #0,d0
  3664.     rts
  3665. .ok1
  3666.     sub.l    cheight(pc),d0
  3667.     addq.l    #1,d0
  3668.     bpl.b    .ok
  3669.     moveq    #0,d0
  3670. .ok
  3671.     move.l    d0,(a0)
  3672.     bra.w    textredraw
  3673.  
  3674. nextpage:
  3675.     lea    linepos(pc),a0
  3676.     move.l    (a0),d0
  3677.     move.l    d0,d7
  3678.     add.l    cheight(pc),d0
  3679.     subq.l    #1,d0
  3680.     move.l    d0,(a0)
  3681.     bsr.w    fixlinepos
  3682.     cmp.l    linepos(pc),d7
  3683.     bne.b    .ok
  3684.     moveq    #0,d0
  3685.     rts
  3686. .ok
  3687.     bra.w    textredraw
  3688.  
  3689.  
  3690. prevpagescroll:
  3691.     move.l    fonty(pc),d0
  3692.     move.l    cheight(pc),d1
  3693.     subq.l    #1,d1
  3694.     bra.w    scrolldown
  3695.  
  3696. nextpagescroll:
  3697.     move.l    fonty(pc),d0
  3698.     move.l    cheight(pc),d1
  3699.     subq.l    #1,d1
  3700.     bra.w    scrollup
  3701.  
  3702. prevpage3:
  3703.     lea    linepos(pc),a0
  3704.     move.l    (a0),d0
  3705.     bne.b    .ok1        ;redan 0 ?
  3706.     moveq    #0,d0
  3707.     rts
  3708. .ok1
  3709.     move.l    cheight(pc),d1
  3710.     mulu.w    #3,d1
  3711.     sub.l    d1,d0
  3712.     bpl.b    .ok
  3713.     moveq    #0,d0
  3714. .ok
  3715.     move.l    d0,(a0)
  3716.     bra.w    textredraw
  3717. nextpage3:
  3718.     lea    linepos(pc),a0
  3719.     move.l    (a0),d0
  3720.     move.l    d0,d7
  3721.     move.l    cheight(pc),d1
  3722.     mulu.w    #3,d1
  3723.     add.l    d1,d0
  3724.     move.l    d0,(a0)
  3725.     bsr.w    fixlinepos
  3726.     cmp.l    linepos(pc),d7
  3727.     bne.b    .ok
  3728.     moveq    #0,d0
  3729.     rts
  3730. .ok
  3731.     bra.w    textredraw
  3732.  
  3733. ;in:
  3734. * d0.w    speed (-4, -3, -2, -1, 0, 1, 2, 3 ,4  0=inget)
  3735. scrollsmooth:
  3736.     ext.l    d0
  3737.     tst.l    d0
  3738.     beq.s    .exit
  3739.     bpl.s    .plus
  3740.     neg.l    d0
  3741.     subq.l    #1,d0
  3742.     moveq    #1,d1
  3743.     lsl.l    d0,d1
  3744.     move.l    d1,d0
  3745.     moveq    #1,d1
  3746.     bra.w    scrolldown
  3747. .plus
  3748.     subq.l    #1,d0
  3749.     moveq    #1,d1
  3750.     lsl.l    d0,d1
  3751.     move.l    d1,d0
  3752.     moveq    #1,d1
  3753.     bra    scrollup
  3754. .exit
  3755.     moveq    #0,d0
  3756.     rts
  3757.  
  3758. scrollup1:
  3759.     move.l    fonty(pc),d0
  3760.     moveq    #1,d1
  3761. scrollup:
  3762.     bsr.b    scrollup_noupdate
  3763.     bsr.w    changescroll
  3764.     moveq    #0,d0
  3765.     rts
  3766. ;in:
  3767. * d0    (Pixel)Lines/Frame (1,2,3,...,fonty,fonty*2,fonty*3,...)
  3768. * d1    Repeat times
  3769. scrollup_noupdate:
  3770.     move.l    d0,.speed
  3771.     move.w    d1,.repeat
  3772.  
  3773.     base    exec
  3774.     move.l    intsignal(pc),d1
  3775.     moveq    #0,d0
  3776.     bset    d1,d0
  3777.     move.l    thistask(pc),a1
  3778.     call    Signal            ;gör en ny signal direkt!
  3779.  
  3780. .nextpass
  3781.     move.l    .speed,d0
  3782.     add.l    fonty(pc),d0
  3783.     subq.l    #1,d0
  3784.     divu.w    fonty+2(pc),d0
  3785.     and.l    #$ffff,d0
  3786.     lea    linepos(pc),a0
  3787.     move.l    (a0),-(sp)
  3788.     add.l    d0,(a0)
  3789.     bsr.w    fixlinepos
  3790.     move.l    (sp)+,d0
  3791.     sub.l    linepos(pc),d0
  3792.     neg.l    d0
  3793.     beq    .exit
  3794.  
  3795.     move.l    fonty(pc),d1
  3796.     cmp.l    .speed(pc),d1
  3797.     bhi.b    .softscroll
  3798.  
  3799.     mulu.w    fonty+2(pc),d0
  3800.     move.l    d0,.speed
  3801.     move.w    #1,.cnt
  3802.     bra.b    .scroll_loop
  3803.  
  3804. .softscroll
  3805.     move.l    fonty(pc),d1
  3806.     divu.w    .speed+2(pc),d1
  3807.     move.w    d1,.cnt
  3808.  
  3809.     move.l    .speed(pc),-(sp)            ;prescroll
  3810.     swap.w    d1
  3811.     move.w    d1,.speed+2
  3812.     beq.b    .noprescroll
  3813.     bsr     .scrollup_and_clear
  3814. .noprescroll
  3815.     move.l    (sp)+,.speed
  3816.  
  3817. .scroll_loop
  3818.     base    exec
  3819.     moveq    #0,d0
  3820.     move.l    intsignal(pc),d1
  3821.     bset    d1,d0
  3822.     call    Wait
  3823.  
  3824.     bsr    .scrollup_and_clear
  3825.  
  3826.     lea    .cnt(pc),a0
  3827.     subq.w    #1,(a0)
  3828.     bne.s    .scroll_loop
  3829.  
  3830.     move.l    .speed(pc),d5
  3831.     add.l    fonty(pc),d5
  3832.     subq.l    #1,d5
  3833.     divu.w    fonty+2(pc),d5
  3834.     and.l    #$ffff,d5
  3835.  
  3836. .printbottom
  3837.     move.l    linepos(pc),d0
  3838.     add.l    cheight(pc),d0
  3839.     sub.l    d5,d0
  3840.     move.l    linelen(pc),a0
  3841.     moveq    #0,d3
  3842.     move.b    (a0,d0.l),d3
  3843.     bsr.w    gotoline
  3844.     cmp.b    #$ff,d3
  3845.     beq.b    .skipline
  3846.     moveq    #0,d1
  3847.     move.l    cheight(pc),d2
  3848.     sub.l    d5,d2
  3849.     bsr.w    print
  3850. .skipline
  3851.     subq.l    #1,d5
  3852.     bne.b    .printbottom
  3853.  
  3854.     lea    .repeat(pc),a0
  3855.     subq.w    #1,(a0)
  3856.     bne.w    .nextpass
  3857. .exit
  3858.     bsr.w    changenum
  3859.     moveq    #0,d0
  3860.     rts
  3861. .speed    dc.l    0
  3862. .repeat    dc.w    0
  3863. .cnt    dc.w    0
  3864.  
  3865. .scrollup_and_clear
  3866.     base    gfx
  3867.  
  3868.     tst.w    legalprint
  3869.     bne.w    .system
  3870.  
  3871.     call    OwnBlitter
  3872.     call    WaitBlit
  3873.     lea    $dff000,a5
  3874.  
  3875.     move.l    #$09f00000,bltcon0(a5)
  3876.     move.l    #-1,bltafwm(a5)
  3877.     move.l    plane0(pc),d0
  3878.     move.l    .speed(pc),d1
  3879.     mulu.w    bwidth+2(pc),d1
  3880.     move.l    d0,bltdpt(a5)
  3881.     add.l    d1,d0
  3882.     move.l    d0,bltapt(a5)
  3883.     move.w    #0,bltamod(a5)
  3884.     move.w    #0,bltdmod(a5)
  3885.     move.l    bwidth(pc),d0
  3886.     lsr.l    #1,d0
  3887.     move.l    cheightp(pc),d1
  3888.     sub.l    .speed(pc),d1
  3889.     btst    #GFXB_BIG_BLITS,gb_ChipRevBits0(a6)
  3890.     bne.b    .bigblit1
  3891.     lsl.l    #6,d1
  3892.     or.l    d0,d1
  3893.     move.w    d1,bltsize(a5)
  3894.     bra.b    .blitted1
  3895. .bigblit1
  3896.     move.w    d1,bltsizv(a5)
  3897.     move.w    d0,bltsizh(a5)
  3898. .blitted1
  3899.     call    WaitBlit
  3900.     move.l    #$01000000,bltcon0(a5)
  3901.     move.l    #-1,bltafwm(a5)
  3902.     move.l    cheightp(pc),d0
  3903.     sub.l    .speed(pc),d0
  3904.     mulu.w    bwidth+2(pc),d0
  3905.     add.l    plane0(pc),d0
  3906.     move.l    d0,bltdpt(a5)
  3907.     move.w    #0,bltdmod(a5)
  3908.  
  3909.     move.l    bwidth(pc),d0
  3910.     lsr.l    #1,d0
  3911.     move.l    .speed(pc),d1
  3912.     btst    #GFXB_BIG_BLITS,gb_ChipRevBits0(a6)
  3913.     bne.b    .bigblit2
  3914.     lsl.l    #6,d1
  3915.     or.l    d0,d1
  3916.     move.w    d1,bltsize(a5)
  3917.     bra.b    .blitted2
  3918. .bigblit2
  3919.     move.w    d1,bltsizv(a5)
  3920.     move.w    d0,bltsizh(a5)
  3921. .blitted2
  3922.     call    DisownBlitter
  3923.     call    WaitBlit
  3924.     rts
  3925. .system
  3926.     move.l    screenptr(pc),a3
  3927.     lea    sc_RastPort(a3),a3
  3928.     move.l    rp_BitMap(a3),a0
  3929.  
  3930.     move.l    .speed(pc),d0
  3931.     move.l    a0,a1
  3932.     suba.l    a2,a2
  3933.     move.l    d0,d1
  3934.     add.l    barheight(pc),d1
  3935.     moveq    #0,d2
  3936.     move.l    d1,d3
  3937.     sub.l    d0,d3
  3938.     move.l    cwidthp(pc),d4
  3939.     move.l    cheightp(pc),d5
  3940.     sub.l    d0,d5
  3941.     move.w    #$c0,d6
  3942.     moveq    #1,d7
  3943.     moveq    #0,d0
  3944.     call    BltBitMap
  3945.  
  3946.     
  3947.     move.l    a3,a1
  3948.     moveq    #0,d0
  3949.     call    SetAPen
  3950.     move.l    a3,a1
  3951.     moveq    #0,d0
  3952.     move.l    cheightp(pc),d1
  3953.     add.l    barheight(pc),d1
  3954.     sub.l    .speed(pc),d1
  3955.     move.l    cwidthp(pc),d2
  3956.     move.l    d1,d3
  3957.     add.l    .speed(pc),d3
  3958.     subq.l    #1,d3
  3959.     call    RectFill
  3960.     rts
  3961.  
  3962. scrolldown1:
  3963.     move.l    fonty(pc),d0
  3964.     moveq    #1,d1
  3965. scrolldown:
  3966.     bsr.b    scrolldown_noupdate
  3967.     bsr.w    changescroll
  3968.     moveq    #0,d0
  3969.     rts
  3970. ;in:
  3971. * d0    (Pixel)Lines/Frame (1,2,4,8,16,24,32,40,...)
  3972. * d1    Repeat times
  3973. scrolldown_noupdate:
  3974.     move.l    d0,.speed
  3975.     move.w    d1,.repeat
  3976.  
  3977.     base    exec
  3978.     move.l    intsignal(pc),d1
  3979.     moveq    #0,d0
  3980.     bset    d1,d0
  3981.     move.l    thistask(pc),a1
  3982.     call    Signal            ;gör en ny signal direkt!
  3983.  
  3984. .nextpass
  3985.     move.l    .speed,d0
  3986.     add.l    fonty(pc),d0
  3987.     subq.l    #1,d0
  3988.     divu.w    fonty+2(pc),d0
  3989.     and.l    #$ffff,d0
  3990.     lea    linepos(pc),a0
  3991.     sub.l    d0,(a0)
  3992.     bpl.s    .notbeg
  3993.     move.l    (a0),d1
  3994.     clr.l    (a0)
  3995.     add.l    d1,d0
  3996.     beq.w    .exit
  3997. .notbeg
  3998.     move.l    fonty(pc),d1
  3999.     cmp.l    .speed(pc),d1
  4000.     bhi.b    .softscroll
  4001.  
  4002.     mulu.w    fonty+2(pc),d0
  4003.     move.l    d0,.speed
  4004.     move.w    #1,.cnt
  4005.     bra.b    .scroll_loop
  4006.  
  4007. .softscroll
  4008.     move.l    fonty(pc),d1
  4009.     divu.w    .speed+2(pc),d1
  4010.     move.w    d1,.cnt
  4011.  
  4012.     move.l    .speed(pc),-(sp)            ;prescroll
  4013.     swap.w    d1
  4014.     move.w    d1,.speed+2
  4015.     beq.b    .noprescroll
  4016.     bsr     .scrolldown_and_clear
  4017. .noprescroll
  4018.     move.l    (sp)+,.speed
  4019.  
  4020. .scroll_loop
  4021.     base    exec
  4022.     moveq    #0,d0
  4023.     move.l    intsignal(pc),d1
  4024.     bset    d1,d0
  4025.     call    Wait
  4026.  
  4027.     bsr    .scrolldown_and_clear
  4028.  
  4029.     lea    .cnt(pc),a0
  4030.     subq.w    #1,(a0)
  4031.     bne.s    .scroll_loop
  4032.  
  4033.     move.l    .speed(pc),d5
  4034.     add.l    fonty(pc),d5
  4035.     subq.l    #1,d5
  4036.     divu.w    fonty+2(pc),d5
  4037.     subq.l    #1,d5
  4038.     and.l    #$ffff,d5
  4039. .printtop
  4040.     move.l    linepos(pc),d0
  4041.     add.l    d5,d0
  4042.     move.l    linelen(pc),a0
  4043.     moveq    #0,d3
  4044.     move.b    (a0,d0.l),d3
  4045.     bsr.w    gotoline
  4046.     cmp.b    #$ff,d3
  4047.     beq.w    .skipline
  4048.     moveq    #0,d1
  4049.     move.l    d5,d2
  4050.     bsr.w    print
  4051. .skipline
  4052.     dbf    d5,.printtop
  4053.  
  4054.     lea    .repeat(pc),a0
  4055.     subq.w    #1,(a0)
  4056.     bne.w    .nextpass
  4057. .exit
  4058.     bsr.w    changenum
  4059.     moveq    #0,d0
  4060.     rts
  4061. .speed    dc.l    0
  4062. .repeat    dc.w    0
  4063. .cnt    dc.w    0
  4064.  
  4065. .scrolldown_and_clear
  4066.     base    gfx
  4067.  
  4068.     tst.w    legalprint
  4069.     bne.w    .system
  4070.  
  4071.     call    OwnBlitter
  4072.     call    WaitBlit
  4073.     lea    $dff000,a5
  4074.  
  4075.     move.l    #$09f00002,bltcon0(a5)
  4076.     move.l    #-1,bltafwm(a5)
  4077.     move.l    cheightp(pc),d0
  4078.     move.l    .speed(pc),d1
  4079.     mulu.w    bwidth+2(pc),d0
  4080.     mulu.w    bwidth+2(pc),d1
  4081.     add.l    plane0(pc),d0
  4082.     subq.l    #2,d0
  4083.     move.l    d0,bltdpt(a5)
  4084.     sub.l    d1,d0
  4085.     move.l    d0,bltapt(a5)
  4086.     move.w    #0,bltamod(a5)
  4087.     move.w    #0,bltdmod(a5)
  4088.     move.l    bwidth(pc),d0
  4089.     lsr.l    #1,d0
  4090.     move.l    cheightp(pc),d1
  4091.     sub.l    .speed(pc),d1
  4092.     btst    #GFXB_BIG_BLITS,gb_ChipRevBits0(a6)
  4093.     bne.b    .bigblit1
  4094.     lsl.l    #6,d1
  4095.     or.l    d0,d1
  4096.     move.w    d1,bltsize(a5)
  4097.     bra.b    .blitted1
  4098. .bigblit1
  4099.     move.w    d1,bltsizv(a5)
  4100.     move.w    d0,bltsizh(a5)
  4101. .blitted1
  4102.     call    WaitBlit
  4103.     move.l    #$01000000,bltcon0(a5)
  4104.     move.l    #-1,bltafwm(a5)
  4105.     move.l    plane0(pc),bltdpt(a5)
  4106.     move.w    #0,bltdmod(a5)
  4107.  
  4108.     move.l    bwidth(pc),d0
  4109.     lsr.l    #1,d0
  4110.     move.l    .speed(pc),d1
  4111.     btst    #GFXB_BIG_BLITS,gb_ChipRevBits0(a6)
  4112.     bne.b    .bigblit2
  4113.     lsl.l    #6,d1
  4114.     or.l    d0,d1
  4115.     move.w    d1,bltsize(a5)
  4116.     bra.b    .blitted2
  4117. .bigblit2
  4118.     move.w    d1,bltsizv(a5)
  4119.     move.w    d0,bltsizh(a5)
  4120. .blitted2
  4121.     call    DisownBlitter
  4122.     call    WaitBlit
  4123.     rts
  4124. .system
  4125.     move.l    screenptr(pc),a3
  4126.     lea    sc_RastPort(a3),a3
  4127.     move.l    rp_BitMap(a3),a0
  4128.  
  4129.     move.l    .speed(pc),d0
  4130.     move.l    a0,a1
  4131.     suba.l    a2,a2
  4132.     move.l    barheight(pc),d1
  4133.     moveq    #0,d2
  4134.     move.l    d1,d3
  4135.     add.l    d0,d3
  4136.     move.l    cwidthp(pc),d4
  4137.     move.l    cheightp(pc),d5
  4138.     sub.l    d0,d5
  4139.     move.w    #$c0,d6
  4140.     moveq    #1,d7
  4141.     moveq    #0,d0
  4142.     call    BltBitMap
  4143.  
  4144.     move.l    a3,a1
  4145.     moveq    #0,d0
  4146.     call    SetAPen
  4147.     move.l    a3,a1
  4148.     moveq    #0,d0
  4149.     move.l    barheight(pc),d1
  4150.     move.l    cwidthp(pc),d2
  4151.     move.l    d1,d3
  4152.     add.l    .speed(pc),d3
  4153.     subq.l    #1,d3
  4154.     call    RectFill
  4155.  
  4156.     rts
  4157.  
  4158. **** text maintaining
  4159.  
  4160. textredraw:
  4161.     bsr.W    fixlinepos
  4162.     bsr.w    changescroll
  4163.     bsr.w    changenum
  4164.     bsr.w    cls
  4165.     move.l    linepos(pc),d0
  4166.     bsr.w    gotoline
  4167.     move.l    a0,d1            ;INTE d0 !! (Bara tst.l    a0)
  4168.     beq.b    .notext
  4169.     bsr.w    printpage
  4170.     bra.b    .exit
  4171. .notext                    ;Inte? Skriv ut © då!
  4172.     moveq    #0,d1
  4173.     moveq    #0,d2
  4174.     move.w    #.hailtextend-.hailtext-1,d3
  4175.     lea    .hailtext(pc),a0
  4176.     bsr.w    print
  4177. .exit
  4178.     moveq    #0,d0
  4179.     rts
  4180. ;FIXIT! Localize it!
  4181. .hailtext
  4182.  dc.b "Textread v"
  4183.  releasestr
  4184.  dc.b " - Copyright ©1992-1995 Martin Blom.",10
  4185.  dc.b "Shareware! Don't forget to send 40 SEK, 20 DM or US$ 10 to:",10,10
  4186.  dc.b "  Martin Blom",10
  4187.  dc.b "  Alsättersgatan 15A.24",10
  4188.  dc.b "S-582 51 Linköping",10
  4189.  dc.b "  Sweden",10,10
  4190.  dc.b "And yes, I prefer SEK. Send comments, bugreports and support letters to",10
  4191.  dc.b "the address above or why not email me:",10,10
  4192.  dc.b "lcs@lysator.liu.se or d93marbl@und.ida.liu.se"
  4193. .hailtextend
  4194.     even
  4195.  
  4196. fixlinepos:
  4197.     pushm    d1/a0
  4198.     move.l    lines(pc),d1
  4199.     sub.l    cheight(pc),d1
  4200.     bmi.b    .minus
  4201.     lea    linepos(pc),a0
  4202.     cmp.l    (a0),d1
  4203.     bhs.b    .ok
  4204.     move.l    d1,(a0)
  4205.     bra.b    .ok
  4206. .minus
  4207.     lea.l    linepos(pc),a0
  4208.     clr.l    (a0)
  4209. .ok
  4210.     popm    d1/a0
  4211.     rts
  4212.  
  4213. printhelp:
  4214.     base    intui
  4215.     move.l    windowptr(pc),a0
  4216.     move.l    #IDCMP_GADGETDOWN!IDCMP_GADGETUP!IDCMP_MOUSEBUTTONS!IDCMP_VANILLAKEY!IDCMP_RAWKEY,d0
  4217.     call    ModifyIDCMP
  4218.  
  4219.     move.l    windowptr(pc),a0
  4220.     or.l    #WFLG_RMBTRAP,wd_Flags(a0)
  4221.  
  4222.     bsr.w    cls
  4223.     moveq    #0,d1
  4224.     moveq    #0,d2
  4225.     move.w    #.helptextend-.helptext-1,d3
  4226.     lea    .helptext(pc),a0
  4227.     bsr.w    print
  4228.  
  4229.     move.l    windowptr(pc),a0
  4230.     move.l    wd_UserPort(a0),a2
  4231.     move.l    a2,a0
  4232.     base    exec
  4233.     call    WaitPort
  4234. .next
  4235.     move.l    a2,a0
  4236.     call    GetMsg
  4237.     tst.l    d0
  4238.     beq.b    .null
  4239.     move.l    d0,a1
  4240.     call    ReplyMsg
  4241.     bra.b    .next
  4242. .null
  4243.     base    intui
  4244.     move.l    windowptr(pc),a0
  4245.     move.l    #IDCMP_INACTIVEWINDOW!IDCMP_MOUSEBUTTONS!IDCMP_MENUVERIFY!IDCMP_MOUSEBUTTONS!ARROWIDCMP!SCROLLERIDCMP!IDCMP_REFRESHWINDOW!IDCMP_MENUPICK!IDCMP_VANILLAKEY!IDCMP_RAWKEY,d0
  4246.     call    ModifyIDCMP
  4247.  
  4248.     move.l    windowptr(pc),a0
  4249.     and.l    #~WFLG_RMBTRAP,wd_Flags(a0)
  4250.     bsr.w    textredraw
  4251.     moveq    #0,d0
  4252.     rts
  4253. ;FIXIT! Localize it!
  4254. .helptext
  4255.  dc.b 'Keys used in Textread',10
  4256.  dc.b '¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯',10
  4257.  dc.b ' Help, H, ? ....................... Show this helppage.',10
  4258.  dc.b ' Q, Shift Esc, Ctrl C ............. Quit Textread.',10
  4259.  dc.b ' Esc .............................. Close current buffer/Quit.',10
  4260.  dc.b ' Down, Return, Enter .............. Scroll text down.',10
  4261.  dc.b ' Left, Shift Up, BackSpace, PgUp .. Show previous page.',10
  4262.  dc.b ' Right, Shift Down, Space, PgDn ... Show next page.',10
  4263.  dc.b ' Alt Up/Down ...................... Move 3 pages up/down.',10
  4264.  dc.b ' Ctrl Up, T, <, Home .............. Go to first page.',10
  4265.  dc.b ' Ctrl Down, B, >, End ............. Go to last page.',10
  4266.  dc.b ' L/# / G/% ........................ Go to line/percent.',10
  4267.  dc.b ' (Shift) F1 - (Shift) F10 ......... Go to (Set) bookmark',10
  4268.  dc.b ' S, "." ........................... Search for string... (no case)',10
  4269.  dc.b ' Shift S, "/" ..................... Search for string... (case)',10
  4270.  dc.b ' N/P .............................. Find next/previous.',10
  4271.  dc.b ' W ................................ Wordwrap on/off.',10
  4272.  dc.b ' Tab .............................. Select tab size...',10
  4273.  dc.b ' Shift-E .......................... Edit text using default editor.',10
  4274.  dc.b ' 1-0 , +/-, Alt Left/Right ........ Change buffer.',10
  4275. .helptextend
  4276.     even
  4277.  
  4278. printpage:
  4279.     pushm    d0-d7/a1-a6
  4280.     tst.w    legalprint
  4281.     bne.b    .system
  4282.     bsr.b    printpage_fast
  4283.     bra.b    .exit
  4284. .system
  4285.     bsr.w    printpage_system
  4286. .exit
  4287.     popm    d0-d7/a1-a6
  4288.     rts
  4289. ;in:
  4290. * a0    text
  4291. * d0    antal rader
  4292. ;ut:
  4293. * a0    text efter sidslut
  4294. printpage_fast:
  4295.     move.l    radpos(pc),a5
  4296.     lea    font,a3
  4297.     move.l    linelen(pc),a6
  4298.     add.l    linepos(pc),a6
  4299.     move.l    bwidth(pc),d4
  4300.     move.l    d0,d5            ;antal rader
  4301.     subq.l    #1,d5
  4302.     bmi.b    .pagefinished
  4303.     moveq    #" ",d2
  4304.     moveq    #TAB,d6
  4305.     moveq    #LF,d7
  4306. .nextline
  4307.     move.l    (a5)+,a1
  4308.     moveq    #0,d1
  4309.     moveq    #0,d3
  4310.     move.b    (a6)+,d3
  4311.     cmp.w    #$ff,d3            ;255 tecken/rad inte ok, utan ev eol.
  4312.     beq.b    .linefinished
  4313. .nextchar
  4314.     moveq    #0,d0
  4315.     move.b    (a0)+,d0
  4316.     cmp.b    d2,d0            ;space
  4317.     beq.b    .space
  4318.     cmp.b    d6,d0            ;tab
  4319.     beq.b    .tab
  4320.     cmp.b    d7,d0            ;lf
  4321.     beq.b    .linefinished
  4322.     lsl.w    #3,d0
  4323.     move.l    a1,a2
  4324.     lea    (a3,d0.w),a4    ;12
  4325.     move.b    (a4)+,(a1)+    ;öka med ett för varje tecken
  4326.      add.w    d4,a2
  4327.     move.b    (a4)+,(a2)
  4328.     add.w    d4,a2
  4329.     move.b    (a4)+,(a2)
  4330.     add.w    d4,a2
  4331.     move.b    (a4)+,(a2)
  4332.     add.w    d4,a2
  4333.     move.b    (a4)+,(a2)
  4334.     add.w    d4,a2
  4335.     move.b    (a4)+,(a2)
  4336.     add.w    d4,a2
  4337.     move.b    (a4)+,(a2)
  4338.     move.b    (a4)+,(a2,d4.w)    ;2c snabbare än add d4,a2 först,6 extra
  4339.     addq.w    #1,d1
  4340. .charfinished
  4341.     dbf    d3,.nextchar
  4342. .linefinished
  4343.     dbf    d5,.nextline
  4344. .pagefinished
  4345.     rts
  4346. .space
  4347.     addq.l    #1,a1
  4348.     addq.w    #1,d1
  4349.     dbf    d3,.nextchar
  4350.     dbf    d5,.nextline
  4351.     rts
  4352. .tab
  4353.     lea    tabbar,a2
  4354.     move.b    (a2,d1.w),d0        ;word rensat
  4355.     sub.w    d1,d0
  4356.     add.w    d0,a1
  4357.     move.b    (a2,d1.w),d1
  4358.     bra.b    .charfinished
  4359.  
  4360. ;in:
  4361. * a0    text
  4362. * d0    antal rader
  4363. ;ut:
  4364. * a0    text efter sidslut
  4365. printpage_system:
  4366.     move.l    linelen(pc),a6
  4367.     add.l    linepos(pc),a6
  4368.     move.w    d0,d5
  4369.     subq.w    #1,d5
  4370.     beq.b    .pagefinished
  4371.  
  4372.     moveq    #0,d1
  4373.     moveq    #0,d2
  4374.  
  4375. .nextline
  4376.     moveq    #0,d3
  4377.     move.b    (a6)+,d3
  4378.     cmp.w    #$ff,d3            ;255 tecken/rad inte ok, utan ev eol.
  4379.     beq.b    .linefinished
  4380.     bsr    print
  4381. .linefinished
  4382.     moveq    #0,d1
  4383.     addq.w    #1,d2
  4384.     dbf    d5,.nextline
  4385. .pagefinished
  4386.     rts
  4387.  
  4388. printline:
  4389.     pushm    d0-d7/a1-a6
  4390.     tst.w    legalprint
  4391.     bne.b    .system
  4392.     bsr.b    printline_fast
  4393.     bra.b    .exit
  4394. .system
  4395.     bsr.w    printline_system
  4396. .exit
  4397.     popm    d0-d7/a1-a6
  4398.     rts
  4399. print:
  4400.     pushm    d0-d7/a1-a6
  4401.     tst.w    legalprint
  4402.     bne.b    .system
  4403.     bsr.b    print_fast
  4404.     bra.b    .exit
  4405. .system
  4406.     bsr.b    print_system
  4407. .exit
  4408.     popm    d0-d7/a1-a6
  4409.     rts
  4410. ;in:
  4411. * d1.w    x-pos (tecken)
  4412. * d2.w    y-pos (print: tecken ; printline: pixels)
  4413. * d3.w    total längd-1 (-1 skriver nästan allt)
  4414. * a0    text
  4415. ;ut:
  4416. * a0    text uppdaterat
  4417. printline_fast:                ;INGA LF!!
  4418.     move.l    plane0(pc),a1
  4419.     mulu.w    bwidth+2(pc),d2
  4420.     add.l    d2,a1
  4421.     bra.b    printit
  4422.  
  4423. print_fast:
  4424.     move.w    d2,d4
  4425.     add.w    d4,d4
  4426.     add.w    d4,d4
  4427.     move.l    radpos(pc),a1
  4428.     move.l    (a1,d4.w),a1
  4429.  
  4430. printit:
  4431.     lea    tabbar,a5
  4432.     lea    font,a3
  4433.     move.l    bwidth(pc),d4
  4434. .nextchar
  4435.     moveq    #0,d0
  4436.     move.b    (a0)+,d0
  4437.     cmp.b    #TAB,d0
  4438.     bne.B    .notab
  4439.     move.b    (a5,d1.w),d1
  4440.     bra.b    .charfinished
  4441. .notab
  4442.     cmp.b    #LF,d0
  4443.     beq.b    .printlf
  4444.     lsl.w    #3,d0
  4445.     lea    (a1,d1.w),a2
  4446.     lea    (a3,d0.w),a4
  4447.     moveq    #8-1,d5                ;fonty?
  4448. .printchar
  4449.     move.b    (a4)+,(a2)
  4450.     add.w    d4,a2
  4451.     dbf    d5,.printchar
  4452.     addq.w    #1,d1
  4453. .charfinished
  4454.     dbf    d3,.nextchar
  4455.     rts
  4456. .printlf
  4457.     moveq    #0,d1
  4458.     addq.w    #1,d2
  4459.     dbf    d3,print_fast
  4460.     rts
  4461.  
  4462. ;in:
  4463. * d1.w    x-pos (tecken)
  4464. * d2.w    y-pos (print: tecken ; printline: pixels)
  4465. * d3.w    total längd-1 (-1 skriver nästan allt)
  4466. * a0    text
  4467. ;ut:
  4468. * a0    text uppdaterat
  4469. print_system:
  4470.     mulu.w    fonty+2(pc),d2
  4471. printline_system:            ;INGA LF!!
  4472.     mulu.w    fontx+2(pc),d1
  4473.     base    gfx
  4474.     move.l    a0,a3
  4475.     move.l    windowptr(pc),a2
  4476.     move.l    wd_RPort(a2),a2
  4477.  
  4478.     add.l    barheight(pc),d2
  4479.     add.w    rp_TxBaseline(a2),d2
  4480.  
  4481.     pushm    a0/d1
  4482.     move.l    a2,a1
  4483.     moveq    #1,d0
  4484.     call    SetAPen
  4485.     move.l    a2,a1
  4486.     moveq    #0,d0
  4487.     call    SetBPen
  4488.     popm    a0/d1
  4489. .nextline
  4490.     pushm    a0/d1
  4491.     move.l    a2,a1
  4492.     move.w    d1,d0
  4493.     move.w    d2,d1
  4494.     call    Move
  4495.     popm    a0/d1
  4496.  
  4497.     lea    temp,a1
  4498.     moveq    #0,d4
  4499.     lea    tabbar,a5
  4500. .nextchar
  4501.     moveq    #0,d0
  4502.     move.b    (a0)+,d0
  4503.     cmp.b    #TAB,d0
  4504.     bne.b    .notab
  4505.  
  4506.     move.b    (a5,d1.w),d0
  4507.     sub.b    d1,d0
  4508.     add.b    d0,d1
  4509.     add.b    d0,d4
  4510.     subq.b    #1,d0
  4511. .filltab
  4512.     move.b    #" ",(a1)+
  4513.     dbf    d0,.filltab
  4514.     bra.b    .charfinished
  4515. .notab
  4516.     cmp.b    #LF,d0
  4517.     beq.b    .printlf
  4518.     move.b    d0,(a1)+
  4519.     addq.w    #1,d4
  4520.     addq.w    #1,d1
  4521. .charfinished
  4522.     dbf    d3,.nextchar
  4523.     pushm    a0/d1
  4524.     lea    temp,a0
  4525.     move.l    a2,a1
  4526.     move.w    d4,d0
  4527.     call    Text
  4528.     popm    a0/d1
  4529.     rts
  4530. .printlf
  4531.     pushm    a0/d1
  4532.     lea    temp,a0
  4533.     move.l    a2,a1
  4534.     move.w    d4,d0
  4535.     call    Text
  4536.     popm    a0/d1
  4537.  
  4538.     moveq    #0,d1
  4539.     add.w    fonty+2(pc),d2
  4540.     dbf    d3,.nextline
  4541.     rts
  4542.  
  4543. ;in:
  4544. * d0    FALSE om Open, TRUE om Save
  4545. ;ut:
  4546. * d0    pek till filnamn med sökväg, eller NULL om fel/cancel
  4547. askfile:
  4548.     lea    filereqsave(pc),a0
  4549.     clr.l    (a0)
  4550.     lea    filereqtitle(pc),a1
  4551.     lea    openfiletext(pc),a2
  4552.     tst.l    d0
  4553.     beq.b    .wasopen
  4554.     addq.l    #TRUE,(a0)
  4555.     lea    savefiletext(pc),a2
  4556. .wasopen
  4557.     move.l    a2,(a1)
  4558.  
  4559.     base    asl
  4560.     move.l    filereqptr(pc),a0
  4561.     lea    filereqtags(pc),a1
  4562.     call    AslRequest
  4563.     tst.l    d0
  4564.     beq.s    .error
  4565.  
  4566.     move.l    filereqptr(pc),a0
  4567.     move.l    fr_Drawer(a0),a1
  4568.     move.l    fr_Pattern(a0),a0
  4569.     lea    filereqdir(pc),a2
  4570.     lea    filereqpat(pc),a3
  4571.     move.w    #255,d0
  4572. .copydir
  4573.     move.b    (a1)+,(a2)+
  4574.     dbeq    d0,.copydir
  4575.     moveq    #63,d0
  4576. .copypat
  4577.     move.b    (a0)+,(a3)+
  4578.     dbeq    d0,.copypat
  4579.  
  4580.     move.l    filereqptr(pc),a0
  4581.     move.l    fr_File(a0),a1
  4582.     move.l    fr_Drawer(a0),a0
  4583.  
  4584.     lea    temp,a2
  4585.     move.w    #tempsize,d0
  4586.     bsr.w    pathnfiletobuff
  4587.     tst.l    d0
  4588.     bmi.b    .error
  4589. .exit
  4590.     move.l    #temp,d0
  4591.     rts
  4592. .error
  4593.     moveq    #0,d0
  4594.     rts
  4595.  
  4596. ;in:
  4597. * d0    pek till filnamn med sökväg
  4598. ;ut:
  4599. * d0    NULL om ok
  4600. openfile:
  4601.     pushm    d1-d7/a0-a6
  4602.     move.l    d0,-(sp)
  4603.  
  4604.     Message    loadingtext
  4605.  
  4606.     move.l    (sp),a0
  4607.     bsr.w    loadfile
  4608.     move.l    d0,d4            ;->
  4609.     move.l    a0,a2
  4610.     move.l    d1,d3
  4611.  
  4612.     base    exec
  4613.     move.l    fileaddr(pc),a1
  4614.     move.l    filememlen(pc),d0
  4615.     beq.B    .nofileinmem
  4616.     call    FreeMem
  4617. .nofileinmem
  4618.     lea    fileaddr(pc),a0
  4619.     move.l    a2,(a0)
  4620.  
  4621.     lea    filememlen(pc),a0
  4622.     move.l    d3,(a0)
  4623.  
  4624.     lea    filelen(pc),a0
  4625.     move.l    d2,(a0)
  4626.     clr.l    linepos
  4627.     lea    fkeys_lines(pc),a0
  4628.     moveq    #9,d0
  4629. .clrpos
  4630.     move.l    #-1,(a0)+
  4631.     dbf    d0,.clrpos
  4632.  
  4633.     move.l    (sp)+,d2
  4634.     move.l    d2,d1
  4635.  
  4636.     base    dos
  4637.     call    FilePart
  4638.     move.l    d0,a0
  4639.     lea    filename(pc),a1
  4640.     moveq    #31,d0
  4641. .copynameloop
  4642.     move.b    (a0)+,(a1)+
  4643.     dbeq    d0,.copynameloop
  4644.  
  4645.     move.l    d2,d1
  4646.     call    PathPart
  4647.     move.l    d0,a0
  4648.     clr.b    (a0)        ;klipp bort filnamnet
  4649.     move.l    d2,a0
  4650.     lea    filereqdir(pc),a1
  4651.     move.w    #255,d0
  4652. .copydirloop
  4653.     move.b    (a0)+,(a1)+
  4654.     dbeq    d0,.copydirloop
  4655.  
  4656.     Message    screentitle
  4657.  
  4658.     tst.l    d4            ;<-
  4659.     bne.b    .exit
  4660.  
  4661.     tst.w    alwaysremansi
  4662.     beq.b    .dontremansi
  4663.     bsr.w    RemoveANSI
  4664. .dontremansi
  4665.     tst.w    alwaysremcr
  4666.     beq.b    .dontremcr
  4667.     bsr.w    RemoveCR
  4668. .dontremcr
  4669.     bsr.w    countlines
  4670.     tst.l    d0
  4671.     bne.b    .error
  4672.     bsr.w    textredraw
  4673.  
  4674. .exit
  4675.     moveq    #0,d0
  4676. .error
  4677.     popm    d1-d7/a0-a6
  4678.     rts
  4679.  
  4680. ;in:
  4681. * a0    filename
  4682. ;ut:
  4683. * d0    0 om ok, -1 om fel
  4684. * d1    filememlen    (allokerat minne)
  4685. * d2    filelen        (filstorlek)
  4686. * a0    fileaddr
  4687. loadfile:
  4688.     clr.l    .addr
  4689.     clr.l    .memlen
  4690.     clr.l    .len
  4691.  
  4692.     base    xpk
  4693.     move.l    a6,d0
  4694.     beq.b    .pp            ;ingen xpk, anv pp
  4695.  
  4696.     move.l    a0,.xpkfilename
  4697.     lea    .xpktags(pc),a0
  4698.     call    XpkUnpack
  4699.     tst.l    d0
  4700.     bne.w    .error
  4701.     bra.w    .fileloadedok
  4702. .pp
  4703.     base    pp            ;a0 klar
  4704.     move.l    a6,d0
  4705.     beq.b    .dos            ;ingen pp, anv dos
  4706.     lea    .addr(pc),a1
  4707.     lea    .len(pc),a2
  4708.     suba.l    a3,a3
  4709.     moveq    #DECR_POINTER,d0
  4710.     moveq    #MEMF_PUBLIC,d1
  4711.     call    ppLoadData
  4712.     tst.l    d0
  4713.     bne.W    .error
  4714.     bra.w    .fileloadedok
  4715. .dos
  4716.     base    dos
  4717.     move.l    a0,d1
  4718.     move.l    #MODE_OLDFILE,d2
  4719.     call    Open
  4720.     move.l    d0,.file
  4721.     bne.s    .dosnoerr1
  4722.     bsr.w    .dosclean
  4723.     lea    errnofile(pc),a1
  4724.     bra.w    .error
  4725. .dosnoerr1
  4726.     moveq    #DOS_FILEHANDLE,d1
  4727.     lea    tag_done(pc),a0
  4728.     move.l    a0,d2
  4729.     call    AllocDosObject
  4730.     move.l    d0,.finfo
  4731.     bne.s    .dosnoerr2
  4732.     bsr.w    .dosclean
  4733.     lea    errnomem(pc),a1
  4734.     bra.w    .error
  4735. .dosnoerr2
  4736.     move.l    .file(pc),d1
  4737.     move.l    .finfo(pc),d2
  4738.     call    ExamineFH
  4739.     tst.l    d0
  4740.     bne.s    .dosnoerr3
  4741.     bsr.s    .dosclean
  4742.     lea    errnofile(pc),a1
  4743.     bra.w    .error
  4744. .dosnoerr3
  4745.     move.l    .finfo(pc),a0
  4746.     move.l    fib_Size(a0),d0
  4747.     lea    .len(pc),a0
  4748.     move.l    d0,(a0)
  4749.     moveq    #MEMF_ANY,d1
  4750.     base    exec
  4751.     call    AllocMem
  4752.     lea    .addr(pc),a0
  4753.     move.l    d0,(a0)
  4754.     bne.s    .dosnoerr4
  4755.     bsr.s    .dosclean
  4756.     lea    errnomem(pc),a1
  4757.     bra.w    .error
  4758. .dosnoerr4
  4759.     base    dos
  4760.     move.l    .file(pc),d1
  4761.     move.l    .addr(pc),d2
  4762.     move.l    .len(pc),d3
  4763.     call    Read
  4764.     cmp.l    d0,d3
  4765.     beq.s    .dosnoerr5
  4766.     bsr.s    .dosclean
  4767.     base    exec
  4768.     move.l    .addr(pc),a1
  4769.     move.l    .len(pc),d0
  4770.     beq.B    .dosnofilemem
  4771.     call    FreeMem
  4772. .dosnofilemem
  4773.     lea    errnofile(pc),a1
  4774.     bra.w    .error
  4775. .dosnoerr5
  4776.     bsr.s    .dosclean
  4777.     bra.s    .fileloadedok
  4778. .dosclean
  4779.     base    dos
  4780.     move.l    .file(pc),d1
  4781.     beq.s    .doserr_nofile
  4782.     clr.l    .file
  4783.     call    Close
  4784. .doserr_nofile
  4785.     move.l    .finfo(pc),d2
  4786.     beq.s    .doserr_nofinfo
  4787.     clr.l    .finfo
  4788.     moveq    #DOS_FILEHANDLE,d1
  4789.     call    FreeDosObject
  4790.     clr.l    .finfo
  4791. .doserr_nofinfo
  4792.     rts
  4793. .fileloadedok
  4794.     move.l    .addr(pc),a0
  4795.     move.l    .memlen(pc),d1
  4796.     bne.b    .memlenok
  4797.     move.l    .len(pc),d1        ;pp & dos har bara 2 tal, xpk har 3
  4798. .memlenok
  4799.     move.l    .len(pc),d2
  4800.  
  4801.     moveq    #0,d0
  4802.     rts
  4803.  
  4804. .addr    dc.l    0
  4805. .len    dc.l    0
  4806. .memlen    dc.l    0
  4807. .file    dc.l    0    ;dosloader
  4808. .finfo    dc.l    0    ;dosloader
  4809.  
  4810. .xpktags
  4811.     dc.l    XPK_InName
  4812. .xpkfilename
  4813.     dc.l    0
  4814.     dc.l    XPK_GetError,XPKerrbuf
  4815.     dc.l    XPK_GetOutBuf,.addr
  4816.     dc.l    XPK_GetOutLen,.len
  4817.     dc.l    XPK_GetOutBufLen,.memlen
  4818.     dc.l    XPK_PassThru,-1
  4819.     dc.l    TAG_DONE
  4820.     even
  4821. ;in:
  4822. * .errbuf Textsträng med felmeddelande
  4823. * eller
  4824. * d0    pp error code
  4825. * eller
  4826. * a1    felmeddelande (dos)
  4827. .error
  4828.     base    xpk
  4829.     move.l    a6,d1
  4830.     beq.b    .pperr
  4831.     lea    XPKerrbuf,a1
  4832.     bra.b    .showerr
  4833. .pperr
  4834.     base    pp
  4835.     move.l    a6,d1
  4836.     beq.b    .doserr
  4837.     call    ppErrorMessage
  4838.     move.l    d0,a1
  4839.     bra.w    .showerr
  4840. .doserr
  4841. .showerr
  4842.     lea    oktext(pc),a2
  4843.     suba.l    a4,a4
  4844.     bsr.w    requester
  4845.  
  4846.     base    exec
  4847.     move.l    .addr(pc),a1
  4848.     move.l    .len(pc),d0
  4849.     beq.B    .noerrorfileinmem
  4850.     call    FreeMem
  4851. .noerrorfileinmem
  4852.     moveq    #-1,d0
  4853.     moveq    #0,d1
  4854.     move    #0,d2
  4855.     suba.l    a0,a0
  4856.     rts
  4857.  
  4858. ;in:
  4859. * d0    pek till filnamn
  4860. ;ut:
  4861. * d0    NULL om ok
  4862. savefile:
  4863.     pushm    d0
  4864.     Message    savingtext
  4865.     base    dos
  4866.     popm    d5                    ;-=>
  4867.     move.l    d5,d1
  4868.     move.l    #MODE_NEWFILE,d2
  4869.     call    Open
  4870.     move.l    d0,d7                    ;->
  4871.     beq.w    .exit
  4872.     move.l    d7,d1                    ;<-
  4873.     move.l    fileaddr(pc),d2
  4874.     move.l    filelen(pc),d3
  4875.     call    Write
  4876.     moveq    #0,d6                    ;=>
  4877.     cmp.l    d0,d3
  4878.     beq.b    .writeok
  4879.  
  4880.     lea    writeerr(pc),a1
  4881.     lea    oktext(pc),a2
  4882.     suba.l    a4,a4
  4883.     bsr    requester
  4884.  
  4885.     moveq    #1,d6                    ;=>
  4886. .writeok
  4887.     base    dos
  4888.     move.l    d7,d1                    ;<-
  4889.     call    Close
  4890.  
  4891.     move.l    d5,d1                    ;<=-
  4892.     base    dos
  4893.     call    FilePart
  4894.     move.l    d0,a0
  4895.     lea    filename(pc),a1
  4896.     moveq    #31,d0
  4897. .copynameloop
  4898.     move.b    (a0)+,(a1)+
  4899.     dbeq    d0,.copynameloop
  4900.  
  4901.     move.l    d5,d1
  4902.     call    PathPart
  4903.     move.l    d0,a0
  4904.     clr.b    (a0)        ;klipp bort filnamnet
  4905.     move.l    d5,a0
  4906.     lea    filereqdir(pc),a1            ;<=-
  4907.     move.w    #255,d0
  4908. .copydirloop
  4909.     move.b    (a0)+,(a1)+
  4910.     dbeq    d0,.copydirloop
  4911.  
  4912. .exit
  4913.     Message    screentitle
  4914.     move.l    d6,d0                    ;<=
  4915.     rts
  4916.  
  4917.  
  4918. ;calls countlines if neccessary (sp?)
  4919. recountlines:
  4920.     move.l    clcwidth(pc),d0
  4921.     cmp.l    cwidth(pc),d0
  4922.     bne.b    countlines
  4923.     rts
  4924.  
  4925. ;ut:
  4926. * d0    0 om ok, eller felkod
  4927. * linelen: pek till minnesblock med radlängder
  4928. * linelensize: minnesblockets storlek
  4929. countlines:
  4930.     Message    counting
  4931.  
  4932. ;    Onödigt. Bättre att man får en rad med längd 255=eol markering.
  4933. ;    lea    filelen(pc),a0
  4934. ;    tst.l    (a0)
  4935. ;    beq.w    .exit
  4936.  
  4937.     base    exec        ;fria gammalt minne
  4938.     move.l    linelen(pc),a1
  4939.     move.l    linelensize(pc),d0
  4940.     beq.b    .ingetlineminne
  4941.     call    FreeMem
  4942. .ingetlineminne
  4943.     lea    linelen(pc),a0
  4944.     lea    notnull(pc),a1            ;pek till 255
  4945.     move.l    a1,(a0)
  4946.     lea    linelensize(pc),a0
  4947.     clr.l    (a0)
  4948.  
  4949. ;    moveq    #LF,d1
  4950. ;    moveq    #0,d0
  4951. ;    move.l    fileaddr(pc),a0
  4952. ;    move.l    filelen(pc),d0
  4953. ;    beq.s    .nofile
  4954. ;.cntlf
  4955. ;    subq.l    #1,d0
  4956. ;    beq.s    .done
  4957. ;    cmp.b    (a0)+,d1
  4958. ;    bne.s    .cntlf
  4959. ;    addq.l    #1,d2
  4960. ;    bra.s    .cntlf
  4961. .done
  4962. .nofile
  4963.  
  4964.     move.l    #1024,d2        ;1024 rader till att börja med
  4965. ;    move.l    filelen(pc),d2
  4966. ;    move.l    cwidth(pc),d0
  4967. ;    divu    d0,d2
  4968. ;    bvc.s    .under64k
  4969. ;    move.w    #$ffff,d2
  4970. ;.under64k
  4971.  
  4972.     cmp.w    #512,d2
  4973.     bhs.s    .sizeok
  4974.     move.w    #512,d2
  4975. .sizeok
  4976.     and.l    #$ffff,d2        ;bort med resten!
  4977.     bsr.w    alloclinemem
  4978.     tst.l    d0
  4979.     beq.w    .error_nomem
  4980.  
  4981.     move.l    fileaddr(pc),a0
  4982.     move.l    a0,a1
  4983.     add.l    filelen(pc),a1
  4984.  
  4985.     lea    tabbar,a2
  4986.     move.l    linelen(pc),a4
  4987.     move.l    linelensize(pc),a5
  4988.     add.l    a4,a5
  4989.     move.l    cwidth(pc),d1
  4990.     subq.l    #1,d1
  4991.     moveq    #1,d2        ;alltid 1 rad!
  4992.     moveq    #LF,d3
  4993.     moveq    #TAB,d4
  4994.     moveq    #" ",d5
  4995.     tst.w    wordwrap
  4996.     bne.B    .ww
  4997. .nextline
  4998.     moveq    #0,d0
  4999.     moveq    #-1,d7
  5000. .huntlf
  5001.     cmp.l    a0,a1        ;sista tecknet
  5002.     beq.b    .klar
  5003.     move.b    (a0)+,d6
  5004.     addq.l    #1,d7
  5005.     cmp.b    d4,d6        ;TAB?
  5006.     bne.B    .notab
  5007.     move.b    (a2,d0.w),d0
  5008.     bra.b    .testok
  5009. .notab
  5010.     addq.l    #1,d0        ;nej,add 1
  5011.     cmp.b    d3,d6        ;LF?
  5012.     beq.B    .lineok
  5013. .testok
  5014.     cmp.l    d1,d0        ;nej fortsätt om ok
  5015.     bls.b    .huntlf
  5016.  
  5017.     move.b    (a0),d6
  5018.     cmp.b    d3,d6        ;LF
  5019.     beq.b    .add1
  5020.     cmp.b    d4,d6        ;TAB?
  5021.     beq.b    .add1
  5022.     cmp.b    d5,d6        ;space
  5023.     bne.b    .lineok
  5024. .add1
  5025.     addq.l    #1,a0
  5026.     addq.l    #1,d7
  5027. .lineok
  5028.     addq.l    #1,d2        ;ja, ny rad
  5029.     move.b    d7,(a4)+
  5030.     cmp.l    a4,a5
  5031.     bne.b    .nextline
  5032.     move.l    d2,-(sp)
  5033.     move.l    linelensize(pc),d2
  5034.     add.l    #1024,d2        ;öka med 1024 i taget
  5035.     bsr.w    alloclinemem
  5036.     move.l    (sp)+,d2
  5037.     tst.l    d0
  5038.     beq.w    .error_nomem
  5039.     move.l    d0,a4
  5040.     move.l    linelen(pc),a5
  5041.     add.l    linelensize(pc),a5
  5042.     bra.b    .nextline
  5043. .klar
  5044.     move.b    d7,(a4)+        ;sista radlängden...
  5045.     lea    lines(pc),a0
  5046.     move.l    d2,(a0)
  5047.     bra.b    .exit
  5048. .ww
  5049. ..nextline
  5050.     moveq    #0,d0
  5051.     suba.l    a3,a3
  5052.     moveq    #-1,d7
  5053.     suba.l    a6,a6
  5054. ..huntlf
  5055.     cmp.l    a0,a1        ;sista tecknet
  5056.     beq.b    .klar
  5057.  
  5058.     move.b    (a0)+,d6
  5059.     addq.l    #1,d7
  5060.     cmp.b    d4,d6        ;TAB?
  5061.     bne.b    ..notab
  5062.     move.l    a0,a3        ;spara tab
  5063.     move.l    d7,a6
  5064.     move.b    (a2,d0.w),d0
  5065.     bra.b    ..testok
  5066. ..notab
  5067.     cmp.b    d5,d6
  5068.     bne.b    ..nospace
  5069.     move.l    a0,a3        ;spara space
  5070.     move.l    d7,a6
  5071. ..nospace
  5072.     addq.l    #1,d0        ;nej,add 1
  5073.     cmp.b    d3,d6        ;LF?
  5074.     beq.B    ..lineok
  5075. ..testok
  5076.     cmp.w    d1,d0        ;nej fortsätt om ok
  5077.     bls.b    ..huntlf
  5078.  
  5079.     move.b    (a0),d6
  5080.     cmp.b    d3,d6        ;LF
  5081.     beq.b    ..add1
  5082.     cmp.b    d4,d6        ;TAB?
  5083.     beq.b    ..add1
  5084.     cmp.b    d5,d6        ;space
  5085.     beq.b    ..add1
  5086.     move.w    a6,d6        ;antingen är första tecknet " " eller TAB eller
  5087.     beq.b    ..lineok    ;bara ett ord.
  5088.     move.l    a3,a0
  5089.     move.l    a6,d7
  5090.     bra.b    ..lineok
  5091. ..add1
  5092.     addq.l    #1,a0
  5093.     addq.l    #1,d7
  5094. ..lineok
  5095.     addq.l    #1,d2        ;ja, ny rad
  5096.     move.b    d7,(a4)+
  5097.     cmp.l    a4,a5
  5098.     bne.b    ..nextline
  5099.     move.l    d2,-(sp)
  5100.     move.l    linelensize(pc),d2
  5101.     add.l    #1024,d2    ;öka med 1024 i taget
  5102.     bsr.w    alloclinemem
  5103.     move.l    (sp)+,d2
  5104.     tst.l    d0
  5105.     beq.b    .error_nomem
  5106.     move.l    d0,a4
  5107.     move.l    linelen(pc),a5
  5108.     add.l    linelensize(pc),a5
  5109.     bra.b    ..nextline
  5110.  
  5111. .exit
  5112.     moveq    #0,d0            ;Eftersom radlängden kanske ändrats,
  5113.     bsr.w    gotoline        ;är det bäst att se till att vi inte
  5114.                     ;är nånstant i mitten på en rad.
  5115.     bsr    updatemenu
  5116.     lea    clcwidth(pc),a0
  5117.     move.l    cwidth(pc),(a0)
  5118.     moveq    #0,d0
  5119.     rts
  5120. .error_nomem
  5121.     bsr.b    .exit
  5122.     lea    clcwidth(pc),a0
  5123.     clr.l    (a0)
  5124.     moveq    #err_nomem,d0
  5125.     rts
  5126.  
  5127. alloclinemem:    ;d2 size
  5128.     movem.l    d1-a6,-(sp)
  5129.     base    exec
  5130.     move.l    d2,d0
  5131.     move.l    #MEMF_PUBLIC!MEMF_CLEAR,d1
  5132.     call    AllocMem
  5133.     move.l    d0,d3            ;->
  5134.     move.l    d0,a2            ;->
  5135.     beq.B    .error
  5136.     move.l    linelensize(pc),d0
  5137.     beq.b    .ingetminne
  5138.     move.l    d0,d1
  5139.     subq.l    #1,d1
  5140.     move.l    linelen(pc),a0
  5141.     move.l    d3,a1            ;<-
  5142. .loop
  5143.     move.b    (a0)+,(a1)+
  5144.     dbf    d1,.loop
  5145.     move.l    a1,a2            ;->
  5146.     move.l    linelen(pc),a1        ;d0 ok
  5147.     call    FreeMem
  5148. .ingetminne
  5149.     lea    linelen(pc),a0
  5150.     move.l    d3,(a0)            ;<-
  5151.     lea    linelensize(pc),a0
  5152.     move.l    d2,(a0)
  5153.     move.l    a2,d0    ;addr att fortsätta    ;<-
  5154. .exit
  5155.     movem.l    (sp)+,d1-a6
  5156.     rts
  5157. .error
  5158.     moveq    #0,d0
  5159.     bra.b    .exit
  5160.  
  5161. **** menus
  5162.  
  5163. ;in:
  5164. * a0    pek till menystrukt
  5165. * a1    pek till statusword
  5166. * d1    förstörs       ¯¯¯¯
  5167. ;ut:
  5168. * d0    0 om ingen förändring, annars 1
  5169. checkmark:
  5170.     moveq    #0,d1
  5171.     move.w    mi_Flags(a0),d0
  5172.     and.w    #CHECKED,d0
  5173.     beq.b    .notchecked
  5174.     moveq    #1,d1
  5175. .notchecked
  5176.     moveq    #0,d0
  5177.     cmp.w    (a1),d1
  5178.     beq.b    .exit
  5179.     moveq    #1,d0
  5180. .exit
  5181.     move.w    d1,(a1)
  5182.     movem.l    d0-a6,-(sp)
  5183.     bsr.w    changenum        ;uppdatera statusbokstäverna därnere!
  5184.     movem.l    (sp)+,d0-a6
  5185.     rts
  5186.  
  5187. updatemenu:
  5188. ;update thisbuffnum
  5189.     move.l    thisbuff(pc),a1
  5190.     lea    bufflist(pc),a0
  5191.     lea    bnum(pc),a2
  5192.     clr.l    (a2)
  5193.     lea    bmax(pc),a3
  5194.     clr.l    (a3)
  5195. .stepdown
  5196.     TSTNODE    a0,a0
  5197.     beq.b    .fel
  5198.     addq.l    #1,(a2)
  5199.     addq.l    #1,(a3)
  5200.     cmp.l    a0,a1
  5201.     bne.b    .stepdown
  5202. .stepdown2
  5203.     TSTNODE    a0,a0
  5204.     beq.b    .klar
  5205.     addq.l    #1,(a3)
  5206.     bra.b    .stepdown2
  5207. .klar
  5208. .fel
  5209.     base    intui
  5210.     lea    bufflist(pc),a0
  5211.     move.l    MLH_HEAD(a0),d0
  5212.     cmp.l    MLH_TAILPRED(a0),d0
  5213.     bne.b    .notlast
  5214.     move.l    windowptr(pc),a0
  5215.     move.w    #$1f<<11!10<<5!0,d0    ;reveal... item
  5216.     call    OffMenu
  5217. ;    move.l    windowptr(pc),a0
  5218. ;    move.w    #$1f<<11!11<<5!0,d0    ;close item
  5219. ;    call    OffMenu
  5220.     bra.b    .closeok
  5221. .notlast
  5222.     move.l    windowptr(pc),a0
  5223.     move.w    #$1f<<11!10<<5!0,d0    ;reveal... item
  5224.     call    OnMenu
  5225. ;    move.l    windowptr(pc),a0
  5226. ;    move.w    #$1f<<11!11<<5!0,d0    ;close item
  5227. ;    call    OnMenu
  5228. .closeok
  5229.     lea.l    legalprint(pc),a0
  5230.     tst.w    (a0)
  5231.     bne.b    .legal
  5232.     move.l    windowptr(pc),a0
  5233.     move.w    #$1f<<11!4<<5!1,d0    ;nofake item
  5234.     call    OnMenu
  5235.     bra.b    .legalchecked
  5236. .legal
  5237.     move.l    windowptr(pc),a0
  5238.     move.w    #$1f<<11!4<<5!1,d0    ;nofake item
  5239.     call    OffMenu
  5240. .legalchecked
  5241.     lea.l    foreignbitmap(pc),a0
  5242.     tst.w    (a0)
  5243.     bne.b    .foreign
  5244.     move.l    windowptr(pc),a0
  5245.     move.w    #$1f<<11!5<<5!1,d0    ;legalprint item
  5246.     call    OnMenu
  5247.     bra.b    .foreignchecked
  5248. .foreign
  5249.     move.l    windowptr(pc),a0
  5250.     move.w    #$1f<<11!5<<5!1,d0    ;nofake item
  5251.     call    OffMenu
  5252. .foreignchecked
  5253.  
  5254.     move.l    diskfontbase(pc),d0
  5255.     bne.b    .diskfontchecked
  5256.     move.l    windowptr(pc),a0
  5257.     move.w    #$1f<<11!10<<5!1,d0    ;nofake item
  5258.     call    OffMenu
  5259. .diskfontchecked
  5260.  
  5261.     lea.l    filelen(pc),a0
  5262.     tst.l    (a0)
  5263.     beq.b    .notextinmem
  5264.     move.l    windowptr(pc),a0
  5265.     move.w    #$1f<<11!$3f<<5!2,d0    ;commands menu
  5266.     call    OnMenu
  5267.     move.l    windowptr(pc),a0
  5268.     move.w    #$1f<<11!7<<5!0,d0    ;print item
  5269.     call    OnMenu
  5270.     pea    menutext(pc)
  5271.     bra.b    .fixmenu
  5272. .notextinmem
  5273.     move.l    windowptr(pc),a0
  5274.     move.w    #$1f<<11!$3f<<5!2,d0    ;commands menu
  5275.     call    OffMenu
  5276.     move.l    windowptr(pc),a0
  5277.     move.w    #$1f<<11!7<<5!0,d0    ;print item
  5278.     call    OffMenu
  5279.     pea    menuemptytext(pc)
  5280. .fixmenu
  5281.     base    exec
  5282.     lea    screentitle,a3
  5283.     move.l    (sp)+,a0
  5284.     lea    .args(pc),a1
  5285.     move.l    lines(pc),16(a1)
  5286.     lea    .rawdofmtfunc(pc),a2
  5287.     call    RawDoFmt
  5288.  
  5289.     Message    screentitle
  5290.     rts
  5291.  
  5292. .rawdofmtfunc
  5293.     move.b    d0,(a3)+
  5294.     rts
  5295.  
  5296. .releasestr
  5297.     releasestr
  5298.     dc.b    0
  5299.     even
  5300.  
  5301. .args
  5302.     dc.l    .releasestr
  5303. bnum:    dc.l    0    ;buffer #
  5304. bmax:    dc.l    0
  5305.     dc.l    filename
  5306.     dc.l    0    ;lines
  5307.  
  5308. updatecheckmarks:
  5309.     base    intui
  5310.     move.l    windowptr(pc),a0
  5311.     call    ClearMenuStrip
  5312.  
  5313.     move.l    winmenuptr(pc),a0
  5314. .nextmenu
  5315.     move.l    a0,d1    ;tst!
  5316.     beq.b    .exit
  5317.     move.l    mu_FirstItem(a0),a1
  5318. .nextitem
  5319.     move.l    a1,d1    ;tst!
  5320.     beq.B    .noitem
  5321.     move.l    mi_SubItem(a1),a2
  5322. .nextsub
  5323.     move.l    a2,d1    ;tst!
  5324.     beq.B    .nosub
  5325.  
  5326.     GTMENUITEM_USERDATA    a2,a3
  5327.     move.w    mi_Flags(a2),d1
  5328.     move.w    d1,d3
  5329.     and.w    #CHECKIT,d1
  5330.     beq.b    .nosubflag
  5331.     or.w    #CHECKED,d3    ;sätt
  5332.     tst.w    -(a3)        ;wordet före är status
  5333.     bne.B    .subok        ;om satt
  5334.     and.w    #~CHECKED,d3    ;rensa
  5335. .subok
  5336.     move.w    d3,mi_Flags(a2)
  5337. .nosubflag
  5338.     move.l    mi_NextItem(a2),a2
  5339.     bra.b    .nextsub
  5340. .nosub
  5341.     GTMENUITEM_USERDATA    a1,a3
  5342.     move.w    mi_Flags(a1),d1
  5343.     move.w    d1,d3
  5344.     and.w    #CHECKIT,d1
  5345.     beq.b    .noitemflag
  5346.     or.w    #CHECKED,d3    ;sätt
  5347.     tst.w    -(a3)        ;wordet före är status
  5348.     bne.B    .itemok        ;om satt
  5349.     and.w    #~CHECKED,d3    ;rensa
  5350. .itemok
  5351.     move.w    d3,mi_Flags(a1)
  5352. .noitemflag
  5353.     move.l    mi_NextItem(a1),a1
  5354.     bra.b    .nextitem
  5355. .noitem
  5356.     move.l    mu_NextMenu(a0),a0
  5357.     bra.b    .nextmenu
  5358. .exit
  5359.     move.l    windowptr(pc),a0
  5360.     move.l    winmenuptr(pc),a1
  5361.     call    ResetMenuStrip
  5362.     bsr.w    changenum    ;uppdatera IWSC därnere!
  5363.     moveq    #0,d0
  5364.     rts
  5365.  
  5366. **** find
  5367.  
  5368. search_case:    dc.w    0    ;1=case sensitive
  5369. search_wild:    dc.w    0    ;1=wildcards on
  5370. search_dir:    dc.w    0    ;1=backwards
  5371. search_then:    dc.w    0    ;1=restart
  5372.  
  5373. searchlen:    dc.w    0
  5374.  
  5375. search:
  5376.     tst.l    filelen
  5377.     beq.s    .exit
  5378.     jsr    requestsearch
  5379.     cmp.w    #1,d0
  5380.     bne.s    .exit
  5381.  
  5382.     moveq    #-1,d0
  5383.     lea    searchstring,a0
  5384. .calclen
  5385.     addq.w    #1,d0
  5386.     tst.b    (a0)+
  5387.     bne.b    .calclen
  5388.     lea    searchlen(pc),a0
  5389.     move.w    d0,(a0)
  5390.     tst.w    search_dir
  5391.     bne.w    searchprev
  5392.     bra.w    searchnext
  5393. .exit
  5394.     moveq    #0,d0
  5395.     rts
  5396.  
  5397. ;in:
  5398. * a0    addr to first char found
  5399. * a2    addr to last char found +1 (if a0=a2, mark the whole line)
  5400. searchfound:
  5401.     move.l    a2,a1
  5402.     pushm    a0
  5403.     bsr    searchmarkfound
  5404.     popm    a0
  5405.     bsr.w    getline
  5406.     subq.l    #1,d0
  5407.     lea    linepos(pc),a0
  5408.     move.l    d0,(a0)
  5409.     bsr.w    textredraw
  5410.  
  5411.     bsr    setwritemask
  5412.  
  5413.     move.l    a2,a1
  5414.     moveq    #RP_COMPLEMENT,d0
  5415.     call    SetDrMd
  5416.  
  5417.     move.l    foundlinestart(pc),d1
  5418.     sub.l    linepos(pc),d1
  5419.     bmi.b    .quit
  5420.     cmp.l    cheight(pc),d1
  5421.     bhs.b    .quit
  5422.     mulu.w    fonty+2(pc),d1
  5423.     add.l    barheight(pc),d1
  5424.     move.w    d1,d3
  5425.     add.w    fonty+2(pc),d3
  5426.     subq.w    #1,d3
  5427.     move.w    foundcolstart(pc),d0
  5428.     mulu.w    fontx+2(pc),d0
  5429.     move.w    foundcolend(pc),d2
  5430.     mulu.w    fontx+2(pc),d2
  5431.     move.l    a2,a1
  5432.     call    RectFill
  5433. .quit
  5434.     move.l    a2,a1
  5435.     moveq    #1,d0
  5436.     call    SetAPen
  5437.     move.l    a2,a1
  5438.     moveq    #0,d0
  5439.     call    SetBPen
  5440.     move.l    a2,a1
  5441.     moveq    #RP_JAM2,d0
  5442.     call    SetDrMd
  5443.     moveq    #0,d0
  5444.     rts
  5445.  
  5446. searchnotfound:
  5447.     base    intui
  5448.     move.l    screenptr(pc),a0
  5449.     call    DisplayBeep
  5450.     bra.w    textredraw
  5451. searchnext:
  5452.     tst.l    filelen
  5453.     beq.s    .exit
  5454.     tst.b    searchstring
  5455.     beq.s    searchnotfound
  5456.     Message    searching
  5457.     tst.w    search_wild
  5458.     beq.s    .nowild
  5459.     bsr    searchwildnext
  5460.     bra.s    .exit
  5461. .nowild
  5462.     bsr    searchnowildnext
  5463. .exit
  5464.     Message    screentitle
  5465.     moveq    #0,d0
  5466.     rts
  5467. searchnowildnext:
  5468.     move.l    linepos(pc),d0
  5469.     addq.l    #1,d0
  5470.     bsr.w    gotoline
  5471.     tst.w    search_case
  5472.     beq.W    .case
  5473.     move.l    fileaddr(pc),d0
  5474.     add.l    filelen(pc),d0
  5475.     sub.l    a0,d0
  5476.     beq.w    searchnotfound
  5477.     lea    searchstring,a1
  5478.     move.b    (a1),d1
  5479. .fastsearch
  5480.     cmp.b    (a0)+,d1
  5481.     beq.b    .firstfound
  5482. .fastnextchar
  5483.     subq.l    #1,d0                ;dbf bara word!!
  5484.     bne.b    .fastsearch
  5485.     bra.W    searchnotfound
  5486. .firstfound
  5487.     move.l    a0,a2
  5488.     subq.l    #1,a2
  5489.     move.l    a1,a3
  5490.     move.w    searchlen(pc),d2
  5491.     subq.w    #1,d2
  5492.     bmi.b    .found
  5493. .allsearch
  5494.     cmpm.b    (a2)+,(a3)+
  5495.     bne.b    .fastnextchar
  5496.     dbf    d2,.allsearch
  5497. .found
  5498.     subq.l    #1,a0
  5499.     bra.w    searchfound
  5500. .case
  5501.     move.l    a0,a3
  5502.     lea    searchstring,a2
  5503.     move.b    (a2),d0
  5504.     base    util
  5505.     call    ToUpper
  5506.     move.l    d0,d2
  5507.     call    ToLower
  5508.     move.l    d0,d1
  5509.     move.l    a3,a0
  5510.     move.l    fileaddr(pc),d0
  5511.     add.l    filelen(pc),d0
  5512.     sub.l    a0,d0
  5513.     beq.w    searchnotfound
  5514.     move.l    a2,a1
  5515. .cfastsearch
  5516.     cmp.b    (a0),d1
  5517.     beq.b    .cfirstfound
  5518.     cmp.b    (a0),d2
  5519.     beq.b    .cfirstfound
  5520. .cfastnextchar
  5521.     addq.l    #1,a0
  5522.     subq.l    #1,d0
  5523.     bne.b    .cfastsearch
  5524.     bra.w    searchnotfound
  5525. .cfirstfound
  5526.     move.l    a0,a2
  5527.     move.l    a1,a3
  5528.     move.l    d0,d3
  5529.     move.l    d1,d4
  5530.     moveq    #0,d0
  5531.     move.w    searchlen(pc),d0
  5532.     call    Strnicmp
  5533.     tst.l    d0
  5534.     beq.b    .cfound
  5535.     move.l    a2,a0
  5536.     move.l    a3,a1
  5537.     move.l    d3,d0
  5538.     move.l    d4,d1
  5539.     bra.b    .cfastnextchar
  5540. .cfound
  5541.     move.l    a2,a0
  5542.     add.w    searchlen(pc),a2
  5543.     bra.w    searchfound
  5544.  
  5545. ;in:
  5546. * a0    start of text
  5547. * a1    end of text
  5548. searchmarkfound:
  5549.     pushm    d0-d1/a0-a3
  5550.     move.l    a0,a2
  5551.     move.l    a1,a3
  5552.     bsr    getline
  5553.     subq.l    #1,d0
  5554.     move.l    d0,foundlinestart
  5555.     bsr    gotoline
  5556.  
  5557.     moveq    #0,d1
  5558.     sub.l    a0,a2
  5559.     move.l    a2,d0
  5560.     beq.b    .4
  5561.     subq.l    #1,d0
  5562.     lea    tabbar,a1
  5563. .1
  5564.     cmp.b    #TAB,(a0)+
  5565.     bne.b    .2
  5566.     move.b    (a1,d1.w),d1
  5567.     bra.b    .3
  5568. .2
  5569.     addq.l    #1,d1
  5570. .3
  5571.     dbf    d0,.1
  5572. .4
  5573.     move.w    d1,foundcolstart
  5574.  
  5575.     move.l    a3,a0
  5576.     bsr    getline
  5577.     subq.l    #1,d0
  5578.     move.l    d0,foundlineend
  5579.     bsr    gotoline
  5580.     sub.l    a0,a3
  5581.     move.l    a3,d0
  5582.     bne.b    .notwholeline
  5583.     move.l    linelen(pc),a0
  5584.     add.l    foundlineend(pc),a0
  5585.     move.b    (a0),d0
  5586.     move.w    d0,foundcolend
  5587.     bra.b    .exit
  5588. .notwholeline
  5589.     subq.l    #1,d0
  5590.     moveq    #0,d1
  5591.     lea    tabbar,a1
  5592. .11
  5593.     cmp.b    #TAB,(a0)+
  5594.     bne.b    .12
  5595.     move.b    (a1,d1.w),d1
  5596.     bra.b    .13
  5597. .12
  5598.     addq.l    #1,d1
  5599. .13
  5600.     dbf    d0,.11
  5601.     move.w    d1,foundcolend
  5602. .exit
  5603.     popm    d0-d1/a0-a3
  5604.     rts
  5605.  
  5606. foundlinestart:    dc.l    0
  5607. foundlineend:    dc.l    0
  5608. foundcolstart:    dc.w    0
  5609. foundcolend:    dc.w     0
  5610.  
  5611. searchprev:
  5612.     tst.l    filelen
  5613.     beq.s    .exit
  5614.     tst.b    searchstring
  5615.     beq.w    searchnotfound
  5616.     Message    searching
  5617.     tst.w    search_wild
  5618.     beq.s    .nowild
  5619.     bsr    searchwildprev
  5620.     bra.s    .exit
  5621. .nowild
  5622.     bsr    searchnowildprev
  5623. .exit
  5624.     Message    screentitle
  5625.     moveq    #0,d0
  5626.     rts
  5627.  
  5628. searchnowildprev:
  5629.     move.l    linepos(pc),d0
  5630.     bsr.w    gotoline
  5631.     tst.w    search_case
  5632.     beq.B    .case
  5633.     move.l    fileaddr(pc),d0
  5634.     sub.l    a0,d0
  5635.     neg.l    d0
  5636.     beq.w    searchnotfound
  5637.     lea    searchstring,a1
  5638.     move.b    (a1),d1
  5639. .fastsearch
  5640.     cmp.b    -(a0),d1
  5641.     beq.b    .firstfound
  5642. .fastnextchar
  5643.     subq.l    #1,d0
  5644.     bne.b    .fastsearch
  5645.     dbf    d0,.fastsearch
  5646.     bra.w    searchnotfound
  5647. .firstfound
  5648.     move.l    a0,a2
  5649.     move.l    a1,a3
  5650.     move.w    searchlen(pc),d2
  5651.     subq.w    #1,d2
  5652.     bmi.b    .found
  5653. .allsearch
  5654.     cmpm.b    (a2)+,(a3)+
  5655.     bne.b    .fastnextchar
  5656.     dbf    d2,.allsearch
  5657. .found
  5658.     bra.w    searchfound
  5659. .case
  5660.     move.l    a0,a3
  5661.     lea    searchstring,a2
  5662.     move.b    (a2),d0
  5663.     base    util
  5664.     call    ToUpper
  5665.     move.l    d0,d2
  5666.     call    ToLower
  5667.     move.l    d0,d1
  5668.     move.l    a3,a0
  5669.     move.l    fileaddr(pc),d0
  5670.     sub.l    a0,d0
  5671.     neg.l    d0
  5672.     beq.w    searchnotfound
  5673.     move.l    a2,a1
  5674.     subq.l    #1,a0
  5675. .cfastsearch
  5676.     cmp.b    (a0),d1
  5677.     beq.b    .cfirstfound
  5678.     cmp.b    (a0),d2
  5679.     beq.b    .cfirstfound
  5680. .cfastnextchar
  5681.     subq.l    #1,a0
  5682.     subq.l    #1,d0
  5683.     bne.b    .cfastsearch
  5684.     bra.w    searchnotfound
  5685. .cfirstfound
  5686.     move.l    a0,a2
  5687.     move.l    a1,a3
  5688.     move.l    d0,d3
  5689.     move.l    d1,d4
  5690.     moveq    #0,d0
  5691.     move.w    searchlen(pc),d0
  5692.     call    Strnicmp
  5693.     tst.l    d0
  5694.     beq.b    .cfound
  5695.     move.l    a2,a0
  5696.     move.l    a3,a1
  5697.     move.l    d3,d0
  5698.     move.l    d4,d1
  5699.     bra.b    .cfastnextchar
  5700. .cfound
  5701.     move.l    a2,a0
  5702.     add.w    searchlen(pc),a2
  5703.     bra.w    searchfound
  5704.  
  5705. searchwildnext:
  5706.     move.l    linepos(pc),d0
  5707.     addq.l    #1,d0
  5708.     bsr    gotoline
  5709.  
  5710.     move.l    fileaddr(pc),d0
  5711.     add.l    filelen(pc),d0
  5712.     sub.l    a0,d0
  5713.     beq.w    searchnotfound
  5714.  
  5715.     lea    searchstring,a0
  5716.     lea    temp,a1
  5717.     move.b    #"#",(a1)+
  5718.     move.b    #"?",(a1)+
  5719. .copystr
  5720.     move.b    (a0)+,(a1)+
  5721.     bne.s    .copystr
  5722.     move.b    #"#",-1(a1)
  5723.     move.b    #"?",(a1)+
  5724.     clr.b    (a1)
  5725.  
  5726.     tst.w    search_case
  5727.     bne.s    .casesens1
  5728.     lea    temp,a2                ;V37 bugfix
  5729.     base    util
  5730. .toupper
  5731.     move.b    (a2),d0
  5732.     beq.s    .upperready
  5733.     call    ToUpper
  5734.     move.b    d0,(a2)+
  5735.     bra.s    .toupper
  5736. .upperready
  5737. .casesens1
  5738.     base    dos
  5739.     move.l    #temp,d1
  5740.     move.l    #temp+84,d2
  5741.     move.l    #84*2+2,d3
  5742.     tst.w    search_case
  5743.     bne.s    .casesens2
  5744.     call    ParsePatternNoCase
  5745.     bra.s    .parsed
  5746. .casesens2
  5747.     call    ParsePattern
  5748. .parsed
  5749. ;    tst.l    d0
  5750. ;    beq    searchnowildnext        ;fanns inget wildcard!
  5751.     cmp.l    #-1,d0
  5752.     beq    searchnotfound            ;fel
  5753.  
  5754.     move.l    linepos(pc),d7
  5755.     moveq    #0,d6
  5756. .loop
  5757.     addq.l    #1,d7
  5758.     cmp.l    lines(pc),d7
  5759.     bhs    searchnotfound
  5760.  
  5761.     move.l    d7,d0
  5762.     bsr    gotoline
  5763.     move.l    a0,a2
  5764.  
  5765.  
  5766.     move.l    linelen(pc),a1
  5767.     add.l    d7,a1
  5768.     moveq    #0,d0
  5769.     move.b    (a1),d0
  5770.     move.l    d0,d6
  5771.     beq    .loop
  5772.     subq.w    #1,d0
  5773.     lea    temp+256,a1
  5774. .copysearchstring
  5775.     move.b    (a0)+,(a1)+
  5776.     dbf    d0,.copysearchstring
  5777.     clr.b    (a1)
  5778.     move.l    #temp+84,d1
  5779.     move.l    #temp+256,d2
  5780.     tst.w    search_case
  5781.     bne.s    .casesens3
  5782.     call    MatchPatternNoCase
  5783.     bra.s    .tested
  5784. .casesens3
  5785.     call    MatchPattern
  5786. .tested
  5787.     tst.l    d0
  5788.     beq.s    .loop
  5789.  
  5790.     move.l    a2,a0
  5791.     bra.w    searchfound
  5792.  
  5793. searchwildprev:
  5794.     move.l    linepos(pc),d0
  5795.     bsr.w    gotoline
  5796.     move.l    fileaddr(pc),d0
  5797.     sub.l    a0,d0
  5798.     neg.l    d0
  5799.     beq.w    searchnotfound
  5800.  
  5801.     lea    searchstring,a0
  5802.     lea    temp,a1
  5803.     move.b    #"#",(a1)+
  5804.     move.b    #"?",(a1)+
  5805. .copystr
  5806.     move.b    (a0)+,(a1)+
  5807.     bne.s    .copystr
  5808.     move.b    #"#",-1(a1)
  5809.     move.b    #"?",(a1)+
  5810.     clr.b    (a1)
  5811.  
  5812.     tst.w    search_case
  5813.     bne.s    .casesens1
  5814.     lea    temp,a2                ;V37 bugfix
  5815.     base    util
  5816. .toupper
  5817.     move.b    (a2),d0
  5818.     beq.s    .upperready
  5819.     call    ToUpper
  5820.     move.b    d0,(a2)+
  5821.     bra.s    .toupper
  5822. .upperready
  5823. .casesens1
  5824.     base    dos
  5825.     move.l    #temp,d1
  5826.     move.l    #temp+84,d2
  5827.     move.l    #84*2+2,d3
  5828.     tst.w    search_case
  5829.     bne.s    .casesens2
  5830.     call    ParsePatternNoCase
  5831.     bra.s    .parsed
  5832. .casesens2
  5833.     call    ParsePattern
  5834. .parsed
  5835. ;    tst.l    d0
  5836. ;    beq    searchnowildnext        ;fanns inget wildcard!
  5837.     cmp.l    #-1,d0
  5838.     beq    searchnotfound            ;fel
  5839.  
  5840.     move.l    linepos(pc),d7
  5841.     moveq    #0,d6
  5842. .loop
  5843.     subq.l    #1,d7
  5844.     bmi    searchnotfound
  5845.  
  5846.     move.l    d7,d0
  5847.     bsr    gotoline
  5848.     move.l    a0,a2
  5849.  
  5850.     move.l    linelen(pc),a1
  5851.     add.l    d7,a1
  5852.     moveq    #0,d0
  5853.     move.b    (a1),d0
  5854.     move.l    d0,d6
  5855.     beq    .loop
  5856.     subq.w    #1,d0
  5857.     lea    temp+256,a1
  5858. .copysearchstring
  5859.     move.b    (a0)+,(a1)+
  5860.     dbf    d0,.copysearchstring
  5861.     clr.b    (a1)
  5862.     move.l    #temp+84,d1
  5863.     move.l    #temp+256,d2
  5864.     tst.w    search_case
  5865.     bne.s    .casesens3
  5866.     call    MatchPatternNoCase
  5867.     bra.s    .tested
  5868. .casesens3
  5869.     call    MatchPattern
  5870. .tested
  5871.     tst.l    d0
  5872.     beq.s    .loop
  5873.  
  5874.     move.l    a2,a0
  5875.     bra.w    searchfound
  5876.  
  5877. **** screen/environment functions
  5878.  
  5879. iconify:
  5880.     base    icon
  5881.     lea    .defappiconname(pc),a0
  5882.     call    GetDiskObject
  5883.     lea    .diskobject(pc),a0
  5884.     move.l    d0,(a0)
  5885.  
  5886.     base    exec
  5887.     call    CreateMsgPort
  5888.     move.l    d0,d7
  5889.     beq.W    .nomsgport
  5890.     base    wb
  5891.     move.l    .diskobject(pc),d0
  5892.     move.l    d0,a3
  5893.     bne.b    .usedefappicon
  5894.     lea    AppIconDO,a3    ;diskobj
  5895. .usedefappicon
  5896.     moveq    #0,d0        ;id
  5897.     moveq    #0,d1        ;userdata
  5898.     lea    programname(pc),a0
  5899.     move.l    d7,a1        ;msgport
  5900.     suba.l    a2,a2        ;lock
  5901.     suba.l    a4,a4
  5902.     call    AddAppIconA
  5903.     move.l    d0,d6
  5904.     beq.W    .noicon
  5905.  
  5906.     bsr.w    closeenvironment
  5907.  
  5908. .waitloop
  5909.     base    exec
  5910.  
  5911.     move.l    comport,a0
  5912.     move.b    MP_SIGBIT(a0),d1
  5913.     moveq    #0,d0
  5914.     bset    d1,d0
  5915.     lea    .comsignal(pc),a0
  5916.     move.l    d0,(a0)
  5917.  
  5918.     move.l    d7,a0
  5919.     move.b    MP_SIGBIT(a0),d1
  5920.     moveq    #0,d0
  5921.     bset    d1,d0
  5922.     lea    .appsignal(pc),a0
  5923.     move.l    d0,(a0)
  5924.  
  5925.     move.l    .comsignal(pc),d0
  5926.     or.l    .appsignal(pc),d0
  5927.  
  5928.     call    Wait
  5929.  
  5930.     move.l    d0,d1
  5931.     and.l    .appsignal,d1
  5932.     bne.b    .nextmsg
  5933.  
  5934.     move.l    d0,d1
  5935.     and.l    .comsignal,d1
  5936.     beq.b    .waitloop
  5937.     bsr    .doubleclicked
  5938.     bsr    handleCOM
  5939.     moveq    #1,d0
  5940.     rts
  5941. .nextmsg
  5942.     base    exec
  5943.     move.l    d7,a0
  5944.     call    GetMsg
  5945.     tst.l    d0
  5946.     beq.B    .waitloop
  5947.     move.l    d0,a1
  5948.     move.l    am_NumArgs(a1),d2
  5949.     call    ReplyMsg
  5950.     tst.l    d2
  5951.     beq.B    .doubleclicked
  5952.     base    intui
  5953.     suba.l    a0,a0
  5954.     call    DisplayBeep
  5955.     bra.B    .nextmsg
  5956. .doubleclicked
  5957.     base    wb
  5958.     move.l    d6,a0
  5959.     call    RemoveAppIcon
  5960.     bsr.b    .cleanup
  5961.     bsr.w    changevideomode
  5962.     tst.l    d0
  5963.     bne.b    .exit
  5964.     moveq    #1,d0            ;inga fler meddelanden!
  5965. .exit
  5966.     rts
  5967. .noicon
  5968.     lea    noworkbench(pc),a1
  5969.     lea    oktext(pc),a2
  5970.     suba.l    a4,a4
  5971.     bsr.w    requester
  5972.     bsr.b    .cleanup
  5973.     moveq    #1,d0            ;inga fler meddelanden!
  5974.     rts
  5975. .cleanup
  5976.     base    exec
  5977. .getallmsg
  5978.     move.l    d7,a0
  5979.     call    GetMsg
  5980.     tst.l    d0
  5981.     beq.B    .nomoremsg
  5982.     move.l    d0,a1
  5983.     call    ReplyMsg
  5984.     bra.B    .getallmsg
  5985. .nomoremsg
  5986.     move.l    d7,a0
  5987.     call    DeleteMsgPort
  5988. .nomsgport
  5989.     base    icon
  5990.     move.l    .diskobject(pc),d0
  5991.     beq.b    .nodefappicon
  5992.     move.l    d0,a0
  5993.     call    FreeDiskObject
  5994. .nodefappicon
  5995.     rts
  5996. .comsignal    dc.l    0
  5997. .appsignal    dc.l    0
  5998. .diskobject    dc.l    0
  5999. .defappiconname
  6000.     dc.b    "ENV:Textread/def_app",0
  6001.     even
  6002. ;in:
  6003. * d1    gammalt sysfont
  6004. * d2    gammalt screenmode
  6005. ;ut:
  6006. * d0    NULL eller felkod
  6007. changeenv:
  6008.     pushm    d1-a6
  6009.     cmp.w    sysfont(pc),d1
  6010.     bne.b    .changescreen
  6011.     cmp.l    displayid(pc),d2
  6012.     beq.b    .dontchangescreen
  6013. .changescreen
  6014.     bsr.w    changevideomode
  6015.     tst.l    d0
  6016.     bne.b    .error
  6017. ;    lea    tabbar,a0
  6018. ;    bsr.w    fixatabbar
  6019. ;    bra.b    .exit
  6020. .dontchangescreen
  6021.     lea    tabbar,a0
  6022.     bsr.w    fixatabbar
  6023.  
  6024.     lea    thisfont(pc),a0
  6025.     bsr.w    changefont
  6026.     tst.l    d0
  6027.     beq.b    .fontok
  6028.     lea    topaz8font(pc),a0
  6029.     bsr.w    changefont
  6030.     tst.l    d0
  6031.     bne.b    .error
  6032. .fontok
  6033.     moveq    #FALSE,d0
  6034.     bsr.w    fixafonten
  6035.     bsr    recountlines
  6036.     bsr    updatemenu
  6037.     bsr.w    updatecheckmarks
  6038.  
  6039.     moveq    #0,d0
  6040.     bsr    gotoline
  6041.     bsr.w    textredraw
  6042. .exit
  6043.     moveq    #0,d0
  6044. .error
  6045.     popm    d1-a6
  6046.     rts
  6047.  
  6048. changevideomode:
  6049.     movem.l    d1-a6,-(sp)
  6050.     lea    scrnsysfont+2(pc),a0
  6051.     move.w    sysfont(pc),(a0)
  6052.     bsr.w    closeenvironment
  6053.     bsr.w    openenvironment
  6054.     tst.l    d0
  6055.     beq.b    .ok
  6056.     lea    displayid(pc),a0
  6057.     move.l    #DEFAULT_MONITOR_ID!HIRES_KEY,(a0);ok.. std hires, sysfont=0
  6058.     lea    scrnsysfont(pc),a0
  6059.     clr.l    (a0)
  6060.     lea    sysfont(pc),a0
  6061.     clr.w    (a0)
  6062.     bsr.w    closeenvironment
  6063.     bsr.w    openenvironment
  6064.     tst.l    d0
  6065.     bne.b    .failure        ;skit i det då!
  6066. .ok
  6067.     moveq    #TRUE,d0
  6068.     bsr    fixafonten
  6069.     bsr    updatemenu
  6070.     bsr.w    updatecheckmarks
  6071.     base    intui
  6072.     move.l    screenptr(pc),a0
  6073.     call    ScreenToFront
  6074.     bsr    recountlines
  6075.     bsr.w    textredraw        ;Uppdatera skärm och gadgetar
  6076.     moveq    #0,d0
  6077. .failure
  6078.     movem.l    (sp)+,d1-a6
  6079.     rts
  6080.  
  6081. savefont:    ;a0=8 bytes buffer,a1=31 bytes namnbuffer
  6082.     move.l    windowptr(pc),a3
  6083.     move.l    wd_RPort(a3),a3
  6084.     move.l    rp_Font(a3),a3
  6085.     move.l    LN_NAME(a3),a2
  6086.     move.l    a1,(a0)+
  6087.     move.w    #30,d0
  6088. .copyname
  6089.     move.b    (a2)+,(a1)+
  6090.     dbeq    d0,.copyname
  6091.     move.l    tf_YSize(a3),(a0)+    ;YSize, Style & Flags
  6092.     rts
  6093. changefont:    ;byter font till TextAttr i a0
  6094.     move.l    a0,a2
  6095.     base    gfx
  6096.     move.l    myfont(pc),d0
  6097.     beq.b    .nofont
  6098.     move.l    d0,a1
  6099.     call    CloseFont
  6100.     lea    myfont(pc),a1
  6101.     clr.l    (a1)
  6102. .nofont
  6103.     tst.l    diskfontbase
  6104.     bne.b    .diskfontok
  6105.     base    exec
  6106.     lea    diskfontname(pc),a1
  6107.     moveq    #37,d0
  6108.     call    OpenLibrary        ;öppna diskfont
  6109.     lea    diskfontbase(pc),a0    ;Det är ju inte nödvändigt med
  6110.     move.l    d0,(a0)            ;diskfont.library... alltså:
  6111.     bne.B    .diskfontok
  6112.     base    gfx
  6113.     move.l    a2,a0
  6114.     call    OpenFont
  6115.     bra.b    .fontopened
  6116. .diskfontok
  6117.     base    diskfont
  6118.     move.l    a2,a0
  6119.     call    OpenDiskFont
  6120. .fontopened
  6121.     lea    myfont(pc),a0
  6122.     move.l    d0,(a0)
  6123.     beq.w    .error
  6124.     base    gfx
  6125.     move.l    windowptr(pc),a1
  6126.     move.l    wd_RPort(a1),a1
  6127.     move.l    d0,a0
  6128.     call    SetFont
  6129.     lea    thisfont(pc),a0
  6130.     lea    thisfontname(pc),a1
  6131.     move.l    a1,(a0)+
  6132.     move.l    4(a2),(a0)+
  6133.     move.w    #30,d0
  6134.     move.l    (a2),a0
  6135. .copyname
  6136.     move.b    (a0)+,(a1)+
  6137.     dbeq    d0,.copyname
  6138.  
  6139.     move.l    myfont(pc),a0
  6140.     moveq    #0,d0
  6141.     move.w    tf_XSize(a0),d0
  6142.     lea    fontx(pc),a1
  6143.     move.l    (a1),d1                    ;-> d1
  6144.     move.l    d0,(a1)
  6145.     move.w    tf_YSize(a0),d0
  6146.     lea    fonty(pc),a1
  6147.     move.l    d0,(a1)
  6148.  
  6149.     move.l    pwidth(pc),d0
  6150.     divu.w    fontx+2(pc),d0
  6151.     and.l    #$ffff,d0
  6152.     lea    cwidth(pc),a0
  6153.     move.l    d0,(a0)
  6154.     mulu.w    fontx+2(pc),d0
  6155.     lea    cwidthp(pc),a0
  6156.     move.l    d0,(a0)
  6157.  
  6158.     move.l    pheight(pc),d0
  6159.     sub.l    barheight(pc),d0
  6160.     sub.l    fonty(pc),d0
  6161.     subq.l    #4,d0                    ;plats för bevelbox
  6162.     divu.w    fonty+2(pc),d0
  6163.     and.l    #$ffff,d0
  6164.     lea    cheight(pc),a0
  6165.     move.l    d0,(a0)
  6166.     mulu.w    fonty+2(pc),d0
  6167.     lea    cheightp(pc),a0
  6168.     move.l    d0,(a0)
  6169.  
  6170. ;    cmp.l    fontx(pc),d1                ;<- d1
  6171. ;    beq.b    .samex
  6172. ;    bsr    countlines                ;width was changed!
  6173. ;.samex
  6174.     base    exec
  6175.     move.l    radpos(pc),d0
  6176.     beq.b    .noradpos
  6177.     move.l    d0,a1
  6178.     call    FreeVec
  6179. .noradpos
  6180.     move.l    cheight(pc),d0
  6181.     lsl.l    #2,d0
  6182.     moveq    #MEMF_ANY,d1
  6183.     call    AllocVec
  6184.     lea    radpos(pc),a0
  6185.     move.l    d0,(a0)
  6186.     beq.b    .error
  6187.     move.l    d0,a0
  6188.     move.l    plane0(pc),d1
  6189.     move.l    bwidth(pc),d2
  6190.     mulu.w    fonty+2(pc),d2
  6191.     move.l    cheight(pc),d0
  6192.     subq.w    #1,d0
  6193. .loop
  6194.     move.l    d1,(a0)+
  6195.     add.l    d2,d1
  6196.     dbf    d0,.loop
  6197.  
  6198.     moveq    #0,d0
  6199.     rts
  6200. .error
  6201.     moveq    #err_nofont,d0
  6202.     rts
  6203.  
  6204. ;in:
  6205. * a0    tabbar (256 bytes buffert)
  6206. fixatabbar:
  6207.     move.l    tabsize(pc),d1
  6208.     move.w    d1,d4
  6209.     subq    #1,d1
  6210.     move.w    #255,d2        ;max radlängd?
  6211.     moveq    #0,d3
  6212. .loop1
  6213.     move.w    d1,d0
  6214.     add.b    d4,d3
  6215.     bne.B    .loop2
  6216.     moveq    #-1,d3        ;om 256, ta 255 istället...
  6217. .loop2
  6218.     move.b    d3,(a0)+
  6219.     dbf    d0,.loop2
  6220.     sub.w    d4,d2
  6221.     cmp.w    d1,d2
  6222.     bpl.B    .loop1
  6223.     rts
  6224.  
  6225. ;in:
  6226. * d0    TRUE: force update ; FALSE: Only update if different font
  6227. fixafonten:        ;fixar font-data. Om inte fonten är 8*8 öppnas
  6228.             ;topaz.font 8 ROM-fonten.
  6229.     tst.l    d0
  6230.     beq.b    .dontforceupdate
  6231.     lea    oldfontsize(pc),a0
  6232.     clr.w    (a0)
  6233. .dontforceupdate
  6234.     tst.w    legalprint
  6235.     beq.w    .fast
  6236.  
  6237.     lea    .minmax(pc),a0
  6238.     bsr    getfontlimits
  6239.  
  6240.     move.l    windowptr(pc),a2
  6241.     move.l    wd_RPort(a2),a2
  6242.  
  6243.     move.w    rp_TxHeight(a2),d1
  6244.     move.w    rp_TxWidth(a2),d1
  6245.  
  6246.     move.w    .minmax+2(pc),d0
  6247.     cmp.w    rp_TxHeight(a2),d0
  6248.     bhi.b    .change            ;<min?
  6249.     move.w    .minmax+6(pc),d0
  6250.     cmp.w    rp_TxHeight(a2),d0
  6251.     blo.b    .change            ;>max?
  6252.  
  6253.     move.w    .minmax(pc),d0
  6254.     cmp.w    rp_TxWidth(a2),d0
  6255.     bhi.b    .change            ;<min?
  6256.     move.w    .minmax+4(pc),d0
  6257.     cmp.w    rp_TxWidth(a2),d0
  6258.     blo.b    .change            ;>max?
  6259.     bra.w    .exit
  6260. .change
  6261.     lea    topaz8font(pc),a0
  6262.     moveq    #0,d0
  6263.     bsr.w    changefont
  6264.     tst.l    d0
  6265.     bne.w    .error
  6266.     bra.w    .exit
  6267. .minmax
  6268.     dc.w    8,8,8,8
  6269. .fast
  6270. .again
  6271.     lea    temp,a5
  6272.     move.w    #255,d0
  6273. .fixfonttable
  6274.     move.b    d0,(a5,d0.w)
  6275.     dbf    d0,.fixfonttable
  6276.     
  6277.     base    gfx
  6278.     move.l    windowptr(pc),a2
  6279.     move.l    wd_RPort(a2),a2
  6280.     move.l    plane0(pc),a3
  6281.     lea    font,a4
  6282.  
  6283.     move.l    barheight(pc),d4
  6284.     add.w    rp_TxBaseline(a2),d4
  6285.  
  6286.     cmp.w    #8,rp_TxHeight(a2)
  6287.     bne.w    .no88
  6288.     cmp.w    #8,rp_TxWidth(a2)
  6289.     bne.w    .no88
  6290.  
  6291.     bsr    issamefont        ;if same font, no need to rebuild it
  6292.     tst.l    d0
  6293.     bne    .exit
  6294.  
  6295.     move.l    a2,a1            ;initera rätta färger!
  6296.     moveq    #1,d0
  6297.     call    SetAPen
  6298.     move.l    a2,a1
  6299.     moveq    #0,d0
  6300.     call    SetBPen
  6301.  
  6302.     move.l    a2,a1
  6303.     moveq    #0,d0
  6304.     move.l    d4,d1
  6305.     call    Move
  6306.  
  6307.     lea    (a5),a0
  6308.     tst.w    nofontfake
  6309.     bne.b    .notfaked00
  6310.     move.l    a2,a1
  6311.     moveq    #0,d0
  6312.     call    SetAPen
  6313.     move.l    a2,a1
  6314.     moveq    #1,d0
  6315.     call    SetBPen
  6316.     lea    $40(a5),a0        ;inv 40 = 00
  6317. .notfaked00
  6318.     move.l    a2,a1
  6319.     moveq    #32,d0
  6320.     call    Text
  6321.     move.l    a2,a1
  6322.     moveq    #1,d0
  6323.     call    SetAPen
  6324.     move.l    a2,a1
  6325.     moveq    #0,d0
  6326.     call    SetBPen
  6327.     move.l    a2,a1
  6328.     lea    $20(a5),a0
  6329.     moveq    #32,d0
  6330.     call    Text
  6331.     bsr.w    .copytext
  6332.     move.l    a2,a1
  6333.     moveq    #0,d0
  6334.     move.l    d4,d1
  6335.     call    Move
  6336.     move.l    a2,a1
  6337.     lea    $40(a5),a0
  6338.     moveq    #64,d0
  6339.     call    Text
  6340.     bsr.W    .copytext
  6341.  
  6342.     move.l    a2,a1
  6343.     moveq    #0,d0
  6344.     move.l    d4,d1
  6345.     call    Move
  6346.  
  6347.     lea    $80(a5),a0
  6348.     tst.w    nofontfake
  6349.     bne.b    .notfaked80
  6350.     move.l    a2,a1
  6351.     moveq    #0,d0
  6352.     call    SetAPen
  6353.     move.l    a2,a1
  6354.     moveq    #1,d0
  6355.     call    SetBPen
  6356.     lea    $c0(a5),a0        ;inv c0 = 80
  6357. .notfaked80
  6358.     move.l    a2,a1
  6359.     moveq    #32,d0
  6360.     call    Text
  6361.     move.l    a2,a1
  6362.     moveq    #1,d0
  6363.     call    SetAPen
  6364.     move.l    a2,a1
  6365.     moveq    #0,d0
  6366.     call    SetBPen
  6367.     move.l    a2,a1
  6368.     lea    $a0(a5),a0
  6369.     moveq    #32,d0
  6370.     call    Text
  6371.     bsr.B    .copytext
  6372.  
  6373.     move.l    a2,a1
  6374.     moveq    #0,d0
  6375.     move.l    d4,d1
  6376.     call    Move
  6377.     move.l    a2,a1
  6378.     moveq    #0,d0
  6379.     move.l    d4,d1
  6380.     call    Move
  6381.     move.l    a2,a1
  6382.     lea    $c0(a5),a0
  6383.     moveq    #64,d0
  6384.     call    Text
  6385.     bsr.B    .copytext
  6386. .exit
  6387.     bsr    issamefont
  6388.     tst.l    d0
  6389.     bne.b    .1
  6390.  
  6391.     bsr.w    freegadgets
  6392.     bsr.w    creategadgets
  6393.     tst.l    d0
  6394.     bne.b    .error
  6395. .1
  6396.     moveq    #0,d0
  6397. .error
  6398.     lea    oldfontsize(pc),a1
  6399.     move.w    thisfontsize(pc),(a1)
  6400.     lea    thisfontname(pc),a0
  6401.     lea    oldfontname,a1
  6402. .copyfontname
  6403.     move.b    (a0)+,(a1)+
  6404.     bne.b    .copyfontname
  6405.     rts
  6406. .no88
  6407.     lea    topaz8font(pc),a0
  6408.     moveq    #0,d0
  6409.     bsr.w    changefont
  6410.     tst.l    d0
  6411.     bne.w    .error
  6412.     bra.w    .again
  6413.  
  6414. .copytext
  6415.     moveq    #63,d0
  6416.     moveq    #0,d2
  6417.     move.l    bwidth(pc),d3
  6418. .nextchar
  6419.     move.l    a3,a0
  6420.     add.l    d2,a0
  6421.     addq.l    #1,d2
  6422.     moveq    #7,d1
  6423. .copychar
  6424.     move.b    (a0),(a4)+
  6425.     clr.b    (a0)
  6426.     add.l    d3,a0
  6427.     dbf    d1,.copychar
  6428.     dbf    d0,.nextchar
  6429.     rts
  6430.  
  6431. ;ut:
  6432. * d0    TRUE if the same font, else FALSE.
  6433. issamefont:
  6434.     move.w    oldfontsize(pc),d0
  6435.     beq.b    .change
  6436.     cmp.w    thisfontsize(pc),d0
  6437.     bne.w    .change
  6438.  
  6439.     lea    thisfontname(pc),a0
  6440.     lea    oldfontname,a1
  6441. .nextchar
  6442.     move.b    (a0)+,d0
  6443.     beq.b    .exit
  6444.     cmp.b    (a1)+,d0
  6445.     beq.b    .nextchar
  6446. .change
  6447.     moveq    #FALSE,d0
  6448.     dc.w    $0c40
  6449. .exit
  6450.     moveq    #TRUE,d0
  6451.     rts
  6452.  
  6453. topaz8font:
  6454.     dc.l    .name
  6455.     dc.w    8
  6456.     dc.b    0
  6457.     dc.b    FPF_ROMFONT!FPF_DESIGNED
  6458. .name
  6459.     dc.b    "topaz.font",0
  6460.     even
  6461.  
  6462. openlibs:
  6463.     lea    _SysBase(pc),a0
  6464.     move.l    4.w,(a0)
  6465.  
  6466.     base    exec
  6467.     lea    intuiname(pc),a1
  6468.     move.l    a1,a2
  6469.     moveq    #37,d0
  6470.     move.l    d0,d2
  6471.     call    OpenLibrary        ;öppna intuition
  6472.     lea    intuibase(pc),a0
  6473.     move.l    d0,(a0)
  6474.     beq.w    .error
  6475.  
  6476.     lea    gfxname(pc),a1
  6477.     move.l    a1,a2
  6478.     moveq    #37,d0
  6479.     move.l    d0,d2
  6480.     call    OpenLibrary        ;öppna gfx
  6481.     lea    gfxbase(pc),a0
  6482.     move.l    d0,(a0)
  6483.     beq.w    .error
  6484.     lea    dosname(pc),a1
  6485.     move.l    a1,a2
  6486.     moveq    #37,d0
  6487.     move.l    d0,d2
  6488.     call    OpenLibrary        ;öppna dos
  6489.     lea    dosbase(pc),a0
  6490.     move.l    d0,(a0)
  6491.     beq.w    .error
  6492.     lea    gadtoolsname(pc),a1
  6493.     move.l    a1,a2
  6494.     moveq    #37,d0
  6495.     move.l    d0,d2
  6496.     call    OpenLibrary        ;öppna gadtools
  6497.     lea    gtbase(pc),a0
  6498.     move.l    d0,(a0)
  6499.     beq.w    .error
  6500.     lea    aslname(pc),a1
  6501.     move.l    a1,a2
  6502.     moveq    #37,d0
  6503.     move.l    d0,d2
  6504.     call    OpenLibrary        ;öppna asl
  6505.     lea    aslbase(pc),a0
  6506.     move.l    d0,(a0)
  6507.     beq.w    .error
  6508.     lea    wbname(pc),a1
  6509.     move.l    a1,a2
  6510.     moveq    #37,d0
  6511.     move.l    d0,d2
  6512.     call    OpenLibrary        ;öppna workbench
  6513.     lea    wbbase(pc),a0
  6514.     move.l    d0,(a0)
  6515.     beq.B    .error
  6516.     lea    iconname(pc),a1
  6517.     move.l    a1,a2
  6518.     moveq    #37,d0
  6519.     move.l    d0,d2
  6520.     call    OpenLibrary        ;öppna icon
  6521.     lea    iconbase(pc),a0
  6522.     move.l    d0,(a0)
  6523.     beq.B    .error
  6524.     lea    utilname(pc),a1
  6525.     move.l    a1,a2
  6526.     moveq    #37,d0
  6527.     move.l    d0,d2
  6528.     call    OpenLibrary        ;öppna utility
  6529.     lea    utilbase(pc),a0
  6530.     move.l    d0,(a0)
  6531.     beq.B    .error
  6532.  
  6533.     lea    xpkname(pc),a1
  6534.     move.l    a1,a2
  6535.     moveq    #0,d0
  6536.     move.l    d0,d2
  6537.     call    OpenLibrary        ;öppna xpk
  6538.     lea    xpkbase(pc),a0
  6539.     move.l    d0,(a0)
  6540.     bne.b    .filelibsopened
  6541.                
  6542.     lea    ppname(pc),a1
  6543.     move.l    a1,a2
  6544.     moveq    #35,d0
  6545.     move.l    d0,d2
  6546.     call    OpenLibrary        ;öppna powerpacker, om inte xpk
  6547.     lea    ppbase(pc),a0
  6548.     move.l    d0,(a0)
  6549. ;    beq.B    .error            ;tjahapps. inget funkade. So what?
  6550. .filelibsopened
  6551.  
  6552.     moveq    #0,d0
  6553.     rts
  6554.  
  6555. * a2    library som inte kunde öppnas
  6556. * d2    version
  6557. .error
  6558.     lea    .args(pc),a0
  6559.     move.l    a2,(a0)+
  6560.     move.l    d2,(a0)
  6561.     base    intui
  6562.     move.l    a6,d0
  6563.     beq.b    .errnointui
  6564.     suba.l    a0,a0
  6565.     lea    .strukt(pc),a1
  6566.     suba.l    a2,a2
  6567.     lea    .args(pc),a3
  6568.     call    EasyRequestArgs
  6569.     bra.b    .exit
  6570. .errnointui
  6571.     ALERT    AN_Unknown!AG_OpenLib!AO_Intuition
  6572. .exit
  6573.     moveq    #err_exitnow,d0
  6574.     rts
  6575. .strukt
  6576.     dc.l    .struktend-*
  6577.     dc.l    0
  6578.     dc.l    0
  6579.     dc.l    errnolibtext
  6580.     dc.l    oktext
  6581. .struktend
  6582. .args    dc.l    0,0
  6583.  
  6584. openenvironment:
  6585.     movem.l    d1-a6,-(sp)
  6586.     base    intui
  6587.     lea    screenerrorcode(pc),a0
  6588.     clr.l    (a0)
  6589.     moveq    #err_noscreen,d7
  6590.     suba.l    a0,a0
  6591.     lea    screentags(pc),a1
  6592.     call    OpenScreenTagList
  6593.     lea    screenptr(pc),a0
  6594.     move.l    d0,(a0)
  6595.     beq.w    .error
  6596.     move.l    screenerrorcode(pc),d1
  6597.     bne.w    .error
  6598.  
  6599.     lea    defpalette,a1
  6600.     bsr    getpalette
  6601.  
  6602.     lea    palette(pc),a1
  6603.     bsr    changepalette
  6604.  
  6605.     base    intui
  6606.     move.l    screenptr(pc),a0
  6607.  
  6608.     moveq    #0,d0
  6609.     move.w    sc_Width(a0),d0
  6610.     lea    windowwidth(pc),a1
  6611.     move.l    d0,(a1)
  6612.     lea    pwidth(pc),a1
  6613.     move.l    d0,(a1)            ;pwidth
  6614.  
  6615.     moveq    #0,d0
  6616.     move.b    sc_BarHeight(a0),d0
  6617.     addq.l    #1,d0
  6618.     lea    barheight(pc),a1
  6619.     move.l    d0,(a1)            ;barheight
  6620.  
  6621.     lea    sc_RastPort(a0),a1
  6622.     move.l    rp_BitMap(a1),a1
  6623.     moveq    #0,d0
  6624.     move.w    bm_BytesPerRow(a1),d0
  6625.     lea    bwidth(pc),a2
  6626.     move.l    d0,(a2)            ;bwidth
  6627.  
  6628.     mulu.w    barheight+2(pc),d0
  6629.     add.l    bm_Planes(a1),d0
  6630.     lea    plane0(pc),a1
  6631.     move.l    d0,(a1)
  6632.  
  6633.     moveq    #0,d0
  6634.     move.w    sc_Height(a0),d0
  6635.     lea    windowheight(pc),a1
  6636.     move.l    d0,(a1)
  6637.     lea    pheight(pc),a1
  6638.     move.l    d0,(a1)            ;pheight
  6639.  
  6640.     lea    pwidth(pc),a0        ;för bred skärm?
  6641.     cmp.l    #254*8,(a0)
  6642.     bhi.w    .error
  6643.     lea    pheight(pc),a0        ;för hög skärm?
  6644.     cmp.l    #254*8,(a0)
  6645.     bhi.w    .error
  6646.  
  6647.     move.l    screenptr(pc),a0
  6648.     lea    sc_RastPort(a0),a1
  6649.     move.l    rp_BitMap(a1),a1
  6650.     base    gfx
  6651.     cmp.w    #39,LIB_VERSION(a6)
  6652.     blo.s    .noforeignbitmap
  6653.  
  6654.     lea    foreignbitmap(pc),a2
  6655.     clr.w    (a2)
  6656.     move.l    screenptr(pc),a0
  6657.     lea    sc_RastPort(a0),a0
  6658.     move.l    rp_BitMap(a0),a0
  6659.     moveq    #BMA_FLAGS,d1
  6660.     call    GetBitMapAttr
  6661.     and.l    #BMF_STANDARD,d0
  6662.     bne.b    .noforeignbitmap
  6663.     addq.w    #1,(a2)
  6664.     lea    legalprint(pc),a0
  6665.     move.w    #TRUE,(a0)        ;system rendering ON
  6666.     lea    nofontfake(pc),a0
  6667.     move.w    #TRUE,(a0)        ;always on when legalprint=TRUE
  6668. .noforeignbitmap
  6669.  
  6670.     base    intui
  6671.     lea    windowonscreen(pc),a0
  6672.     move.l    screenptr(pc),(a0)
  6673.  
  6674.     moveq    #err_nowin,d7
  6675.     suba.l    a0,a0
  6676.     lea    windowtags(pc),a1
  6677.     call    OpenWindowTagList    ;öppna fönster 1
  6678.     lea    windowptr(pc),a0
  6679.     move.l    d0,(a0)
  6680.     beq.w    .error
  6681.  
  6682.     lea    deffont,a0
  6683.     lea    deffontname,a1
  6684.     bsr.w    savefont
  6685.  
  6686.     lea    thisfont(pc),a0
  6687.     bsr.w    changefont
  6688.     tst.l    d0
  6689.     beq.b    .fontok
  6690.     lea    topaz8font(pc),a0
  6691.     bsr.w    changefont
  6692.     move.l    d0,d7
  6693.     bne.w    .error
  6694. .fontok
  6695.  
  6696.     base    exec
  6697.     suba.l    a1,a1
  6698.     call    FindTask
  6699.     lea    thistask(pc),a0
  6700.     move.l    d0,(a0)
  6701.     move.l    d0,a0
  6702.     lea    defreqscreen(pc),a1
  6703.     move.l    pr_WindowPtr(a0),(a1)
  6704.     move.l    windowptr(pc),pr_WindowPtr(a0)    ;requestrar på skärmen!
  6705.  
  6706.     base    gt
  6707.     move.l    screenptr(pc),a0
  6708.     lea    tag_done(pc),a1
  6709.     call    GetVisualInfoA        ;skaffa visuell information
  6710.     lea    screenvi(pc),a0
  6711.     move.l    d0,(a0)
  6712.  
  6713.     lea    winmenuerrorcode(pc),a0
  6714.     clr.l    (a0)
  6715.  
  6716.     moveq    #err_nomenu,d7
  6717.     base    gt
  6718.     lea    winmenu(pc),a0
  6719.     lea    winmenutags(pc),a1
  6720.     call    CreateMenusA
  6721.     lea    winmenuptr(pc),a0    ;skapa menyer
  6722.     move.l    d0,(a0)
  6723.     beq.W    .error
  6724.     move.l    winmenuerrorcode(pc),d1
  6725.     bne.W    .error
  6726.  
  6727. ;    move.l    winmenuprt(pc),a0    ;skapa menyer
  6728.     move.l    d0,a0            ;skapa menyer
  6729.     move.l    screenvi(pc),a1
  6730.     lea    .menutags(pc),a2
  6731.     call    LayoutMenusA
  6732.     tst.l    d0
  6733.     beq.W    .error
  6734.  
  6735.     base    intui
  6736.     move.l    windowptr(pc),a0
  6737.     move.l    winmenuptr(pc),a1
  6738.     call    SetMenuStrip
  6739.  
  6740.     moveq    #err_nogadget,d7
  6741.     bsr.w    creategadgets
  6742.     tst.l    d0
  6743.     bne.w    .error
  6744.  
  6745.     moveq    #err_nofilereq,d7
  6746.     lea    .filereqwindow(pc),a0
  6747.     move.l    windowptr(pc),(a0)
  6748.     lea    filereqhgt(pc),a0
  6749.     move.l    pheight(pc),d0
  6750.     mulu    #7,d0
  6751.     lsr.l    #3,d0
  6752.     move.l    d0,(a0)
  6753.     base    asl
  6754.     moveq    #ASL_FileRequest,d0
  6755.     lea    .filereqtags(pc),a0
  6756.     call    AllocAslRequest    
  6757.     lea    filereqptr(pc),a0
  6758.     move.l    d0,(a0)
  6759.     beq.w    .error
  6760.  
  6761.     lea    setname,a0
  6762.     tst.b    (a0)
  6763.     bne.b    .nosetname
  6764.     lea    defsetname(pc),a0
  6765. .nosetname
  6766.     move.l    a0,a2
  6767.     lea    temp,a1
  6768.     move.w    #tempsize-1,d0
  6769. .copysettingsname
  6770.     move.b    (a0)+,(a1)+
  6771.     dbeq    d0,.copysettingsname
  6772.  
  6773.     base    dos
  6774.     move.l    #temp,d1
  6775.     call    PathPart
  6776.     move.l    d0,a0
  6777.     clr.b    (a0)
  6778.     lea    .setfreqpathpart(pc),a0
  6779.     move.l    #temp,(a0)
  6780.  
  6781.     move.l    a2,d1                ;setname/defsetname!
  6782.     call    FilePart
  6783.     lea    .setfreqfilepart(pc),a0
  6784.     move.l    d0,(a0)
  6785.     move.l    d0,a0
  6786.  
  6787.     moveq    #err_nofilereq,d7
  6788.     lea    .setfreqwindow(pc),a0
  6789.     move.l    windowptr(pc),(a0)
  6790.     lea    setfreqhgt(pc),a0
  6791.     move.l    pheight(pc),d0
  6792.     mulu    #7,d0
  6793.     lsr.l    #3,d0
  6794.     move.l    d0,(a0)
  6795.     base    asl
  6796.     moveq    #ASL_FileRequest,d0
  6797.     lea    .setfreqtags(pc),a0
  6798.     call    AllocAslRequest    
  6799.     lea    setfreqptr(pc),a0
  6800.     move.l    d0,(a0)
  6801.     beq.s    .error
  6802.  
  6803. ;    jsr     SetupScreen        ;GTBX
  6804.     moveq    #0,d7
  6805. .error
  6806.     move.l    d7,d0
  6807.     movem.l    (sp)+,d1-a6
  6808.     rts
  6809. .menutags
  6810.     dc.l    GTMN_NewLookMenus,TRUE
  6811.     dc.l    TAG_DONE
  6812.  
  6813. .setfreqtags
  6814.     dc.l    ASLFR_Window
  6815. .setfreqwindow
  6816.     dc.l    0
  6817.     dc.l    ASLFR_DoPatterns,TRUE
  6818.     dc.l    ASLFR_SleepWindow,TRUE
  6819.     dc.l    ASLFR_InitialFile
  6820. .setfreqfilepart
  6821.     dc.l    0
  6822.     dc.l    ASLFR_InitialDrawer
  6823. .setfreqpathpart
  6824.     dc.l    0
  6825.     dc.l    ASLFR_InitialPattern,.setfreqpat
  6826.     dc.l    TAG_DONE
  6827. .setfreqpat
  6828.     dc.b    "#?.prefs",0
  6829.     even
  6830. .filereqtags:
  6831.     dc.l    ASLFR_Window
  6832. .filereqwindow:
  6833.     dc.l    0
  6834.     dc.l    ASLFR_DoPatterns,TRUE
  6835.     dc.l    ASLFR_SleepWindow,TRUE
  6836.     dc.l    TAG_DONE
  6837.  
  6838. setfreqtags:
  6839.     dc.l    ASLFR_InitialHeight
  6840. setfreqhgt:
  6841.     dc.l    100
  6842.     dc.l    ASLFR_DoSaveMode
  6843. setfreqsave:
  6844.     dc.l    FALSE
  6845.     dc.l    ASLFR_TitleText
  6846. setfreqtitle:
  6847.     dc.l    0
  6848.     dc.l    TAG_DONE
  6849.     even
  6850.  
  6851. filereqtags:
  6852.     dc.l    ASLFR_InitialFile,filename
  6853.     dc.l    ASLFR_InitialDrawer,filereqdir
  6854.     dc.l    ASLFR_InitialPattern,filereqpat
  6855.     dc.l    ASLFR_InitialHeight
  6856. filereqhgt:
  6857.     dc.l    100
  6858.     dc.l    ASLFR_DoSaveMode
  6859. filereqsave:
  6860.     dc.l    FALSE
  6861.     dc.l    ASLFR_TitleText
  6862. filereqtitle:
  6863.     dc.l    0
  6864.     dc.l    TAG_DONE
  6865.  
  6866. closeenvironment:
  6867.     movem.l    d1-a6,-(sp)
  6868. ;    jsr    CloseDownScreen        ;GTBX
  6869.     base    asl
  6870.     move.l    setfreqptr(pc),a0
  6871.     clr.l    setfreqptr
  6872.     call    FreeAslRequest
  6873. .nosetfreq
  6874.     move.l    filereqptr(pc),a0
  6875.     clr.l    filereqptr
  6876.     call    FreeAslRequest
  6877. .nofilereq
  6878.     base    intui
  6879.     move.l    windowptr(pc),d0
  6880.     move.l    d0,a0
  6881.     beq.B    .nowindow_menu
  6882.     call    ClearMenuStrip
  6883. .nowindow_menu
  6884.     move.l    thistask(pc),d0
  6885.     beq.b    .nodefreq
  6886.     move.l    d0,a0
  6887.     move.l    defreqscreen(pc),pr_WindowPtr(a0)
  6888. .nodefreq
  6889.     base    exec
  6890.     call    Forbid
  6891.     base    gt
  6892. .nextmsg
  6893.     move.l    windowptr(pc),d0
  6894.     move.l    d0,a0
  6895.     beq.B    .nowindow
  6896.  
  6897.     move.l    wd_UserPort(a0),a0
  6898.     call    GT_GetIMsg
  6899.     tst.l    d0
  6900.     beq.b    .nullmsg
  6901.     move.l    d0,a1
  6902.     call    GT_ReplyIMsg
  6903.     bra.b    .nextmsg
  6904. .nullmsg
  6905.     base    intui
  6906.     move.l    windowptr(pc),a0
  6907.     call    CloseWindow
  6908.     lea    windowptr(pc),a0
  6909.     clr.l    (a0)
  6910. .nowindow
  6911.     base    exec
  6912.     call    Permit
  6913.  
  6914.     base    gt
  6915.     move.l    winmenuptr(pc),d0
  6916.     move.l    d0,a0
  6917.     beq.B    .nowinmenu
  6918.     call    FreeMenus
  6919.     lea    winmenuptr(pc),a0
  6920.     clr.l    (a0)
  6921. .nowinmenu
  6922.     bsr.w    freegadgets
  6923.     move.l    gtbase(pc),a6
  6924.     move.l    screenvi(pc),d0
  6925.     move.l    d0,a0
  6926.     beq.B    .noscreenvi
  6927.     call    FreeVisualInfo
  6928.     lea    screenvi(pc),a0
  6929.     clr.l    (a0)
  6930. .noscreenvi
  6931.     move.l    intuibase(pc),a6
  6932.     move.l    screenptr(pc),d0
  6933.     move.l    d0,a0
  6934.     beq.B    .noscreen
  6935.     call    CloseScreen
  6936.     lea    screenptr(pc),a0
  6937.     clr.l    (a0)
  6938. .noscreen
  6939.     base    gfx
  6940.     move.l    myfont(pc),d0
  6941.     beq.b    .nofont
  6942.     move.l    d0,a1
  6943.     call    CloseFont
  6944.     lea    myfont(pc),a0
  6945.     clr.l    (a0)
  6946. .nofont
  6947.     base    exec
  6948.     move.l    radpos(pc),d0
  6949.     beq.b    .noradpos
  6950.     move.l    d0,a1
  6951.     call    FreeVec
  6952.     lea    radpos(pc),a0
  6953.     clr.l    (a0)
  6954. .noradpos
  6955.     movem.l    (sp)+,d1-a6
  6956.     moveq    #0,d0
  6957.     rts
  6958. closelibs:
  6959.     base    exec
  6960.     move.l    xpkbase(pc),d0
  6961.     beq.B    .noxpkbase
  6962.     move.l    d0,a1
  6963.     call    CloseLibrary
  6964.     lea    xpkbase(pc),a0
  6965.     clr.l    (a0)
  6966. .noxpkbase
  6967.     move.l    ppbase(pc),d0
  6968.     beq.B    .noppbase
  6969.     move.l    d0,a1
  6970.     call    CloseLibrary
  6971.     lea    ppbase(pc),a0
  6972.     clr.l    (a0)
  6973. .noppbase
  6974.     move.l    utilbase(pc),d0
  6975.     beq.B    .noutilbase
  6976.     move.l    d0,a1
  6977.     call    CloseLibrary
  6978.     lea    utilbase(pc),a0
  6979.     clr.l    (a0)
  6980. .noutilbase
  6981.     move.l    iconbase(pc),d0
  6982.     beq.B    .noiconbase
  6983.     move.l    d0,a1
  6984.     call    CloseLibrary
  6985.     lea    iconbase(pc),a0
  6986.     clr.l    (a0)
  6987. .noiconbase
  6988.     move.l    diskfontbase(pc),d0
  6989.     beq.B    .nodiskbase
  6990.     move.l    d0,a1
  6991.     call    CloseLibrary
  6992.     lea    diskfontbase(pc),a0
  6993.     clr.l    (a0)
  6994. .nodiskbase
  6995.     move.l    wbbase(pc),d0
  6996.     beq.B    .nowbbase
  6997.     move.l    d0,a1
  6998.     call    CloseLibrary
  6999.     lea    wbbase(pc),a0
  7000.     clr.l    (a0)
  7001. .nowbbase
  7002.     move.l    aslbase(pc),d0
  7003.     beq.B    .noaslbase
  7004.     move.l    d0,a1
  7005.     call    CloseLibrary
  7006.     lea    aslbase(pc),a0
  7007.     clr.l    (a0)
  7008. .noaslbase
  7009.     move.l    gtbase(pc),d0
  7010.     beq.B    .nogtbase
  7011.     move.l    d0,a1
  7012.     call    CloseLibrary
  7013.     lea    gtbase(pc),a0
  7014.     clr.l    (a0)
  7015. .nogtbase
  7016.     move.l    intuibase(pc),d0
  7017.     beq.B    .nointuibase
  7018.     move.l    d0,a1
  7019.     call    CloseLibrary
  7020.     lea    intuibase(pc),a0
  7021.     clr.l    (a0)
  7022. .nointuibase
  7023.     move.l    dosbase(pc),d0
  7024.     beq.B    .nodosbase
  7025.     move.l    d0,a1
  7026.     call    CloseLibrary
  7027.     lea    dosbase(pc),a0
  7028.     clr.l    (a0)
  7029. .nodosbase
  7030.     move.l    gfxbase(pc),d0
  7031.     beq.B    .nogfxbase
  7032.     move.l    d0,a1
  7033.     call    CloseLibrary
  7034.     lea    gfxbase(pc),a0
  7035.     clr.l    (a0)
  7036. .nogfxbase
  7037.     moveq    #0,d0
  7038.     rts
  7039.  
  7040. creategadgets:
  7041.     base    gt
  7042.  
  7043.     lea    top(pc),a2
  7044.     move.l    linepos(pc),(a2)
  7045.     lea    total(pc),a2
  7046.     move.l    lines(pc),(a2)
  7047.     lea    synliga(pc),a2
  7048.     move.l    cheight(pc),(a2)
  7049.  
  7050.     lea    gadgetptr(pc),a0
  7051.     call    CreateContext
  7052.     move.l    d0,d7
  7053.  
  7054.     move.l    fonty(pc),d2
  7055.     addq.l    #3,d2
  7056.  
  7057.     move.l    fontx(pc),d3
  7058.     lsl.l    #1,d3                ;'Q'-knappen
  7059.  
  7060.     move.l    fontx(pc),d4
  7061.     mulu.w    #25+2,d4
  7062. ;    addq.l    #4,d4                ;Statustext
  7063.  
  7064.     lea    newgadget(pc),a1
  7065.     move.l    d3,d0
  7066.     add.l    d4,d0
  7067.     move.w    d0,gng_LeftEdge(a1)
  7068.     move.l    pwidth(pc),d1
  7069.     sub.w    d0,d1
  7070.     ble.w    .error
  7071.     move.w    d1,gng_Width(a1)
  7072.  
  7073.     move.l    windowheight(pc),d0
  7074.     sub.l    d2,d0
  7075.     ble.w    .error
  7076.     move.w    d0,gng_TopEdge(a1)
  7077.     move.w    d2,gng_Height(a1)
  7078.     clr.l    gng_GadgetText(a1)
  7079.     lea    thisfont(pc),a0
  7080.     move.l    a0,gng_TextAttr(a1)
  7081.     move.w    #1,gng_GadgetID(a1)
  7082.     clr.l    gng_Flags(a1)
  7083.     move.l    screenvi(pc),gng_VisualInfo(a1)
  7084.     clr.l    gng_UserData(a1)
  7085.     move.l    d7,a0
  7086.     lea    scrollertags(pc),a2
  7087.     move.l    #SCROLLER_KIND,d0
  7088.     call    CreateGadgetA
  7089.     lea    scrollgadget(pc),a0
  7090.     move.l    d0,(a0)
  7091.     beq.W    .error
  7092.  
  7093.     lea    newgadget(pc),a1
  7094.     move.w    #0,gng_LeftEdge(a1)
  7095.     move.l    d3,d0
  7096.     subq.l    #1,d0
  7097.     move.w    d0,gng_Width(a1)
  7098.     lea    .q(pc),a0
  7099.     move.l    a0,gng_GadgetText(a1)
  7100.     move.w    #2,gng_GadgetID(a1)
  7101.     move.l    scrollgadget(pc),a0
  7102.     lea    tag_done(pc),a2
  7103.     move.l    #BUTTON_KIND,d0
  7104.     call    CreateGadgetA
  7105.     lea    quitgadget(pc),a0
  7106.     move.l    d0,(a0)
  7107.     beq.B    .error
  7108.  
  7109.     lea    .drawtags(pc),a1
  7110.     move.l    screenvi(pc),4(a1)
  7111.     move.l    d3,d0
  7112.     move.l    windowheight(pc),d1
  7113.     sub.l    d2,d1
  7114.     move.l    d2,d3
  7115.     move.l    d4,d2
  7116.     subq.l    #1,d2
  7117.     ble.b    .error
  7118.     move.l    screenptr(pc),a0
  7119.     lea    sc_RastPort(a0),a0
  7120.     call    DrawBevelBoxA
  7121.  
  7122.     base    intui
  7123.     move.l    windowptr(pc),a0
  7124.     move.l    gadgetptr(pc),a1
  7125.     suba.l    a2,a2
  7126.     moveq    #0,d0
  7127.     moveq    #-1,d1
  7128.     call    AddGList
  7129.     move.l    windowptr(pc),a1
  7130.     move.l    gadgetptr(pc),a0
  7131.     suba.l    a2,a2
  7132.     moveq    #-1,d0
  7133.     call    RefreshGList
  7134.     base    gt
  7135.     move.l    windowptr(pc),a0
  7136.     suba.l    a1,a1
  7137.     call    GT_RefreshWindow
  7138.     moveq    #0,d0
  7139.     rts
  7140. .error
  7141.     moveq    #-1,d0
  7142.     rts
  7143. .q
  7144.     dc.b    "Q",0
  7145. .drawtags
  7146.     dc.l    GT_VisualInfo,0
  7147.     dc.l    GTBB_Recessed,TRUE
  7148.     dc.l    TAG_DONE
  7149.  
  7150. changenum:
  7151.     moveq    #4,d0
  7152.     lea    linetext(pc),a0
  7153.     lea    temp,a1
  7154. .loop
  7155.     move.b    (a0)+,(a1)+
  7156.     dbf    d0,.loop
  7157.     move.l    linepos(pc),d0
  7158.     bsr.w    numdec
  7159. .copylinenum
  7160.     move.b    (a0)+,(a1)+
  7161.     bne.b    .copylinenum
  7162.     move.b    #" ",-1(a1)
  7163.  
  7164.     move.l    linepos(pc),d0
  7165.     mulu.w    #100,d0
  7166.     move.l    lines(pc),d1
  7167.     sub.l    cheight(pc),d1
  7168.     beq.b    .nodiv
  7169.     divu.w    d1,d0            ;hmm...
  7170. .nodiv
  7171.     and.l    #$0000ffff,d0
  7172.     bsr.w    numdec
  7173.     addq.l    #7,a0
  7174.     move.b    (a0)+,(a1)+
  7175.     move.b    (a0)+,(a1)+
  7176.     move.b    (a0)+,(a1)+
  7177.     move.b    #"%",(a1)+
  7178.     move.b    #" ",(a1)+
  7179.  
  7180.     moveq    #"W",d0            ;små statusbokstäver
  7181.     tst.w    wordwrap
  7182.     bne.b    .wwyes
  7183.     moveq    #" ",d0
  7184. .wwyes
  7185.     move.b    d0,(a1)+
  7186.     moveq    #"A",d0
  7187.     tst.w    alwaysremansi
  7188.     bne.b    .rayes
  7189.     moveq    #" ",d0
  7190. .rayes
  7191.     move.b    d0,(a1)+
  7192.     moveq    #"C",d0
  7193.     tst.w    alwaysremcr
  7194.     bne.b    .rcyes
  7195.     moveq    #" ",d0
  7196. .rcyes
  7197.     move.b    d0,(a1)+
  7198.     moveq    #"F",d0
  7199.     tst.w    nofontfake
  7200.     bne.b    .nfyes
  7201.     moveq    #" ",d0
  7202. .nfyes
  7203.     move.b    d0,(a1)+
  7204.  
  7205.     move.l    windowheight(pc),d2
  7206.     sub.l    barheight(pc),d2
  7207.     sub.l    fonty(pc),d2
  7208.     subq.l    #1,d2
  7209.  
  7210.     move.l    a1,d3
  7211.     lea    temp,a0
  7212.     sub.l    a0,d3
  7213.     subq.l    #1,d3            ;längd ok!
  7214.     moveq    #3,d1
  7215.     bsr.w    printline
  7216.     rts
  7217.  
  7218. changescroll:
  7219.     base    gt
  7220.     lea    changetop(pc),a0
  7221.     move.l    linepos(pc),(a0)
  7222.     lea    changetotal(pc),a0
  7223.     move.l    lines(pc),(a0)
  7224.     move.l    scrollgadget(pc),a0
  7225.     move.l    windowptr(pc),a1
  7226.     suba.l    a2,a2
  7227.     lea    changescrolltags(pc),a3
  7228.     call    GT_SetGadgetAttrsA
  7229.     rts
  7230. changescrolltags:
  7231.     dc.l    GTSC_Top
  7232. changetop:
  7233.     dc.l    0
  7234.     dc.l    GTSC_Total
  7235. changetotal:
  7236.     dc.l    0
  7237.     dc.l    TAG_DONE
  7238.  
  7239. freegadgets:
  7240.     bsr    unsetwritemask
  7241.  
  7242.     lea.l    gadgetptr(pc),a2
  7243.  
  7244.  
  7245.     base    gfx
  7246.     move.l    windowptr(pc),d0
  7247.     beq.b    .nowin
  7248.     move.l    d0,a1
  7249.     move.l    wd_RPort(a1),a1
  7250.     moveq    #0,d0
  7251.     call    SetRast
  7252.  
  7253.     base    intui
  7254.     move.l    windowptr(pc),a0
  7255.     move.l    (a2),d0
  7256.     beq.b    .nogadget
  7257.     move.l    d0,a1
  7258.     moveq    #-1,d0
  7259.     call    RemoveGList
  7260. .nowin
  7261.     base    gt
  7262.     move.l    (a2),d0
  7263.     beq.b    .nogadget
  7264.     move.l    d0,a0
  7265.     call    FreeGadgets
  7266. .nogadget
  7267.     clr.l    (a2)
  7268.     moveq    #0,d0
  7269.     rts
  7270. scrollertags:
  7271.     dc.l    GTSC_Top
  7272. top:
  7273.     dc.l    0
  7274.     dc.l    GTSC_Total
  7275. total:
  7276.     dc.l    0
  7277.     dc.l    GTSC_Visible
  7278. synliga:
  7279.     dc.l    0
  7280.     dc.l    GTSC_Arrows,16
  7281.     dc.l    TAG_DONE
  7282. newgadget:
  7283.     blk.b    gng_SIZEOF,0
  7284. gadgetptr:    dc.l    0
  7285. scrollgadget:    dc.l    0
  7286. quitgadget:    dc.l    0
  7287.  
  7288. ;in:
  7289. * a1    pointer to ULONG:R0,G0,B0,R1,B1,G1,... table to be filled
  7290. getpalette:
  7291.     move.l    screenptr(pc),d0
  7292.     beq.b    .exit
  7293.     move.l    d0,a2
  7294.     lea    sc_ViewPort(a2),a2
  7295.     move.l    vp_ColorMap(a2),a2
  7296.     base    gfx
  7297.     cmp.w    #39,LIB_VERSION(a6)
  7298.     blo.b    .v36
  7299.     moveq    #0,d0
  7300.     moveq    #4,d1
  7301.     move.l    a2,a0
  7302.     call    GetRGB32
  7303.     bra.b    .exit
  7304. .v36
  7305.     moveq    #0,d2
  7306.     move.l    a1,a3
  7307. .nextcol
  7308.     move.l    d2,d0
  7309.     move.l    a2,a0
  7310.     call    GetRGB4
  7311.     move.w    d0,d1
  7312.     bsr.b    .4to32
  7313.     move.l    d1,8(a3)
  7314.  
  7315.     lsr.w    #4,d0
  7316.     move.w    d0,d1
  7317.     lsr.w    #4,d0
  7318.     bsr.b    .4to32
  7319.     move.l    d1,4(a3)
  7320.  
  7321.     lsr.w    #4,d0
  7322.     move.w    d0,d1
  7323.     bsr.b    .4to32
  7324.     move.l    d1,(a3)
  7325.  
  7326.     add.l    #4*3,a3
  7327.     addq.l    #1,d2
  7328.     cmp.w    #4,d2
  7329.     bne.b    .nextcol
  7330. .exit
  7331.     moveq    #0,d0
  7332.     rts
  7333. ;in:
  7334. * d1    4bit
  7335. ;ut:
  7336. * d1    32bit
  7337. .4to32
  7338.     pushm    d0/d2
  7339.     move.l    d1,d0
  7340.     and.l    #15,d0
  7341.     moveq    #0,d1
  7342.     moveq    #8-1,d2
  7343. .4to32_loop
  7344.     lsl.l    #4,d1
  7345.     or.b    d0,d1
  7346.     dbf    d2,.4to32_loop
  7347.     popm    d0/d2
  7348.     rts
  7349. ;in:
  7350. * a1    pointer to ULONG:R0,G0,B0,R1,B1,G1,... table
  7351. changepalette:
  7352.     move.l    screenptr(pc),d0
  7353.     beq.b    .exit
  7354.     move.l    d0,a2
  7355.     lea    sc_ViewPort(a2),a2
  7356.  
  7357.     base    gfx
  7358.     cmp.w    #39,LIB_VERSION(a6)
  7359.     blo.b    .v36
  7360.     lea    colortable,a0
  7361.     move.l    #4<<16!0,(a0)+
  7362.     moveq    #3*4-1,d0
  7363. .copylongs
  7364.     move.l    (a1)+,(a0)+
  7365.     dbf    d0,.copylongs
  7366.     clr.l    (a0)
  7367.     move.l    a2,a0
  7368.     lea    colortable,a1
  7369.     call    LoadRGB32
  7370.     bra.b    .exit
  7371. .v36
  7372.     lea    colortable,a0
  7373.     moveq    #4-1,d0
  7374. .make4table
  7375.     moveq    #0,d2
  7376.     move.l    (a1)+,d1
  7377.     rol.l    #4,d1
  7378.     and.w    #15,d1
  7379.     or.w    d1,d2
  7380.     lsl.w    #4,d2
  7381.     move.l    (a1)+,d1
  7382.     rol.l    #4,d1
  7383.     and.w    #15,d1
  7384.     or.w    d1,d2
  7385.     lsl.w    #4,d2
  7386.     move.l    (a1)+,d1
  7387.     rol.l    #4,d1
  7388.     and.w    #15,d1
  7389.     or.w    d1,d2
  7390.     move.w    d2,(a0)+
  7391.     dbf    d0,.make4table
  7392.     moveq    #4,d0
  7393.     move.l    a2,a0
  7394.     lea    colortable,a1
  7395.     call    LoadRGB4    
  7396. .exit
  7397.     moveq    #0,d0
  7398.     rts
  7399.  
  7400.  
  7401. **** diverse
  7402.  
  7403. setwritemask:
  7404.     base    gfx
  7405.     move.l    windowptr(pc),d0
  7406.     beq.b    .nowin
  7407.     move.l    d0,a2    
  7408.     move.l    wd_RPort(a2),a2
  7409.  
  7410.     cmp.w    #39,LIB_VERSION(a6)
  7411.     bhs.b    .v39
  7412.     move.b    #%00000001,rp_Mask(a2)
  7413.     bra.b    .writemaskset
  7414. .v39
  7415.     move.l    a2,a0
  7416.     moveq    #1,d0
  7417.     jsr    -990(a6)            ;SetMaxPen (V39)
  7418. .writemaskset
  7419. .nowin
  7420.     rts
  7421. unsetwritemask:
  7422.     base    gfx
  7423.     move.l    windowptr(pc),d0
  7424.     beq.b    .nowin
  7425.     move.l    d0,a2
  7426.     move.l    wd_RPort(a2),a2
  7427.  
  7428.     cmp.w    #39,LIB_VERSION(a6)
  7429.     bhs.b    .v39
  7430.     move.b    #%11111111,rp_Mask(a2)
  7431.     bra.b    .writemaskset
  7432. .v39
  7433.     move.l    a2,a0
  7434.     moveq    #3,d0
  7435.     jsr    -990(a6)            ;SetMaxPen (V39)
  7436. .writemaskset
  7437. .nowin
  7438.     rts
  7439.  
  7440. ;in:
  7441. * a1    meddelande
  7442. * a2    gadget
  7443. * a4    NULL eller pek på argumentlista
  7444. requester:
  7445.     movem.l    d1/a0-a4/a6,-(sp)
  7446.     bsr    lockwindow
  7447.     base    intui
  7448.     lea    .strukttext(pc),a0
  7449.     move.l    a1,(a0)
  7450.     lea    .struktgadget(pc),a0
  7451.     move.l    a2,(a0)
  7452.     move.l    windowptr(pc),a0
  7453.     lea    .strukt(pc),a1
  7454.     suba.l    a2,a2
  7455.     move.l    a4,a3
  7456.     call    EasyRequestArgs
  7457.     bsr    unlockwindow
  7458.     movem.l    (sp)+,d1/a0-a4/a6
  7459.     rts
  7460. .strukt
  7461.     dc.l    .struktend-*
  7462.     dc.l    0
  7463.     dc.l    0
  7464. .strukttext
  7465.     dc.l    0
  7466. .struktgadget
  7467.     dc.l    0
  7468. .struktend
  7469.  
  7470. ;in:
  7471. * a2    Window
  7472. * a3    Gadget
  7473. PressButton:
  7474.     pushm    a2/a6
  7475.     BASE    intui
  7476.     move.l    a2,a0
  7477.     move.l    a3,a1
  7478.     call    RemoveGadget
  7479.     or.w    #GFLG_SELECTED,gg_Flags(a3)
  7480.     or.w    #GACT_TOGGLESELECT,gg_Activation(a3)
  7481.     move.l    a2,a0
  7482.     move.l    a3,a1
  7483.     moveq    #-1,d0
  7484.     call    AddGadget
  7485.     move.l    a3,a0
  7486.     move.l    a2,a1
  7487.     suba.l    a2,a2
  7488.     call    RefreshGadgets
  7489.     BASE    dos
  7490.     moveq    #5,d1
  7491.     call    Delay
  7492.     popm    a2/a6
  7493.     rts
  7494. ;in:
  7495. * d1    string
  7496. * d2    pointer to longword
  7497. strtoulong:        ;exactly like dos.library/StrToLong, but unsigned
  7498.     pushm    d2-d4
  7499.     move.l    d1,a0
  7500.     move.l    d2,a1
  7501.     clr.l    (a1)
  7502.     moveq    #0,d3
  7503.     moveq    #0,d4
  7504. .findfirst
  7505.     move.b    (a0)+,d4
  7506.     cmp.b    #" ",d4
  7507.     beq.b    .findfirst
  7508.     cmp.b    #TAB,d4
  7509.     beq.b    .findfirst
  7510.     sub.b    #"0",d4
  7511.     bmi.b    .error
  7512.     cmp.b    #9,d4
  7513.     bhi.b    .error
  7514. .next
  7515.     move.l    d3,d2
  7516.     asl.l    #3,d3
  7517.     add.l    d2,d3
  7518.     add.l    d2,d3
  7519.     add.l    d4,d3
  7520.     move.b    (a0)+,d4
  7521.     sub.b    #"0",d4
  7522.     bmi.b    .klart
  7523.     cmp.b    #9,d4
  7524.     bls.b    .next
  7525. .klart
  7526.     move.l    d3,(a1)
  7527. .error
  7528.     sub.l    d1,a0
  7529.     move.l    a0,d0
  7530.     subq.l    #2,d0
  7531.     popm    d2-d4
  7532.     rts
  7533.  
  7534. ;in:
  7535. * d0    number
  7536. ;ut:
  7537. * a0    dec string (10 bytes: "       777",0)
  7538. * d0    dec string ("777",0)
  7539. numdec:
  7540.     movem.l    d1-d2/a1-a2/a6,-(sp)
  7541.     base    util
  7542.     lea    numdec_buffert,a2
  7543.     move.l    a2,a0
  7544.     lea    .siffror(pc),a1
  7545.     moveq    #9,d1
  7546. .init
  7547.     move.b    #" ",(a0)+
  7548.     dbf    d1,.init
  7549.     clr.b    (a0)
  7550.     moveq    #9,d2
  7551. .loop
  7552.     moveq    #10,d1
  7553.     call    UDivMod32
  7554.     move.b    (a1,d1.w),-(a0)        ;remainder
  7555.     tst.l    d0
  7556.     beq.b    .klar
  7557.     dbf    d2,.loop
  7558. .klar
  7559.     move.l    a0,d0
  7560.     move.l    a2,a0
  7561.     movem.l    (sp)+,d1-d2/a1-a2/a6
  7562.     rts
  7563. .siffror
  7564.     dc.b    '0123456789'
  7565.  
  7566. cls:
  7567.     tst.w    legalprint
  7568.     bne.b    .system
  7569.  
  7570.     base    gfx
  7571.  
  7572.     call    OwnBlitter
  7573.     call    WaitBlit
  7574.     lea    $dff000,a5
  7575.     move.l    #$01000000,bltcon0(a5)
  7576.     move.l    #-1,bltafwm(a5)
  7577.     move.l    plane0(pc),bltdpt(a5)
  7578.     move.w    #0,bltdmod(a5)
  7579.  
  7580.     move.l    bwidth(pc),d0
  7581.     lsr.l    #1,d0
  7582.     move.l    cheightp(pc),d1
  7583.     btst    #GFXB_BIG_BLITS,gb_ChipRevBits0(a6)
  7584.     bne.b    .bigblit
  7585.     lsl.l    #6,d1
  7586.     or.l    d0,d1
  7587.     move.w    d1,bltsize(a5)
  7588.     bra.b    .blitted
  7589. .bigblit
  7590.     move.w    d1,bltsizv(a5)
  7591.     move.w    d0,bltsizh(a5)
  7592. .blitted
  7593.     call    DisownBlitter
  7594.     call    WaitBlit
  7595.     rts
  7596.  
  7597. .system
  7598.     bsr    setwritemask
  7599.     base    gfx
  7600.     move.l    screenptr(pc),a3
  7601.     lea    sc_RastPort(a3),a3
  7602.     move.l    a3,a1
  7603.     moveq    #0,d0
  7604.     call    SetAPen
  7605.     move.l    a3,a1
  7606.     moveq    #0,d0
  7607.     move.l    barheight(pc),d1
  7608.     move.l    cwidthp(pc),d2
  7609.     move.l    cheightp(pc),d3
  7610.     add.l    d1,d3
  7611.     subq.l    #1,d3
  7612.     call    RectFill
  7613.     call    WaitBlit
  7614.     rts
  7615.  
  7616.  
  7617. ;slavefunc
  7618. ;    lea    .keepgoing(pc),a0
  7619. ;    clr.w    (a0)
  7620. ;    base    exec
  7621. ;    call    CreateMsgPort
  7622. ;    lea    slaveport(pc),a0
  7623. ;    move.l    d0,(a0)
  7624. ;    beq.s    .noport
  7625. ;.loop
  7626. ;    move.l    slaveport(pc),a0
  7627. ;    call    WaitPort
  7628. ;.getallmsgs
  7629. ;    base    exec
  7630. ;    move.l    slaveport(pc),a0
  7631. ;    call    GetMsg
  7632. ;    tst.l    d0
  7633. ;    beq.s    .outofmsgs
  7634. ;    move.l    d0,a1
  7635. ;    move.w    slavecmd(a1),d2
  7636. ;    call    ReplyMsg
  7637. ;
  7638. ;    cmp.w    #-1,d2
  7639. ;    bne.s    .noquit
  7640. ;    lea    .keepgoing(pc),a0
  7641. ;    addq.w    #1,(a0)
  7642. ;    bra.s    .getallmsgs
  7643. ;.noquit
  7644. ;
  7645. ;.outofmsgs
  7646. ;    tst.w    .keepgoing
  7647. ;    beq.s    .loop
  7648. ;
  7649. ;    move.l    slaveport(pc),a0
  7650. ;    call    DeleteMsgPort
  7651. ;.noport
  7652. ;    rts                ;avsluta processen!
  7653. ;.keepgoing
  7654. ;    dc.w    0
  7655. ;
  7656. ;slavesendmsg
  7657. ;    base    exec
  7658. ;    move.l    slaveport(pc),a0
  7659. ;    lea    slavemessage(pc),a1
  7660. ;    move.l    comport(pc),MN_REPLYPORT(a1)
  7661. ;    move.w    #slavemessagelen,MN_LENGTH(a1)
  7662. ;    call    PutMsg
  7663. ;    move.l    comport(pc),a0
  7664. ;    call    WaitPort
  7665. ;.getallcommsgs
  7666. ;    move.l    comport(pc),a0
  7667. ;    call    GetMsg
  7668. ;    tst.l    d0
  7669. ;    bne.s    .getallcommsgs
  7670. ;    rts
  7671. ;slaveport
  7672. ;    dc.l    0
  7673. ;slavemessage
  7674. ;    ds.b    MP_SIZE        ;fult!!
  7675. ;slavecmd        =*-slavemessage
  7676. ;    dc.w    0    ;command
  7677. ;    dc.w    0    ;data
  7678. ;slavemessagelen    =*-slavemessage
  7679.  
  7680.  
  7681. **********************************************
  7682.  
  7683. ;;
  7684. ; Strings:
  7685.  
  7686. abouttext:    dc.b    "Textread release %s, version %s.",10
  7687.         dc.b    "Copyright ©1992-1995 Martin Blom.",10
  7688.         dc.b    10
  7689.         dc.b    "Current textfile: %s (%-ld bytes).",10
  7690.         dc.b    "Total free memory: %-ld bytes.",10
  7691.         dc.b    "Largest block: %-ld bytes.",10
  7692.         dc.b    10
  7693.         dc.b    "This program is shareware.",0
  7694.  
  7695. smodetext:    dc.b    "Please chose a screen mode",0
  7696. smodegadget:    dc.b    "PAL|PAL laced|NTSC|NTSC laced|Productivity|Cancel",0
  7697.  
  7698. savetext    dc.b    "Are you sure you want",10
  7699.         dc.b    "to save the file %s?",0
  7700. savegadget    dc.b    "Save|Cancel",0
  7701.  
  7702. errnomem    dc.b    "Out of memory.",0
  7703. nofileloaded    dc.b    "No text loaded.",0
  7704. noworkbench    dc.b    "Workbench isn't open/loaded.",0
  7705. colerrortext:    dc.b    "Unable to run 'Colors'.",0
  7706. errnofile    dc.b    "Unable to open file.",0
  7707. writeerr    dc.b    "Unable to save file.",0
  7708. savesetmessage:    dc.b    "Unable to save settings",0
  7709. errnolibtext    dc.b    "Unable to open",10
  7710.         dc.b    "%s V%ld+.",0
  7711.  
  7712. openfiletext    dc.b    "Open file",0
  7713. savefiletext    dc.b    "Save file",0
  7714. loadsettitle:    dc.b    "Load settings",0
  7715. savesettitle:    dc.b    "Save settings",0
  7716.  
  7717. loadingtext    dc.b    "Loading...",0
  7718. savingtext    dc.b    "Saving...",0
  7719. searching:    dc.b    "Searching...",0
  7720. counting    dc.b    "Counting lines...",0
  7721. remansitext    dc.b    "Removing ANSI codes...",0
  7722. remcrtext    dc.b    "Removing CR (ascii #13) characters...",0
  7723.  
  7724. menutext    dc.b    "Textread %s - Buffer %lu/%lu: %.31s (%lu lines)",0
  7725. menuemptytext    dc.b    "Textread %s - Buffer %lu/%lu (empty)",0
  7726.  
  7727. screenname:    dc.b    "Textread Screen",0
  7728. intname:    dc.b    "Textread VBLANK server",0
  7729. oktext:        dc.b    "Ok",0
  7730. linetext    dc.b    "Line:",0
  7731.  
  7732.     even
  7733.  
  7734. oldfontsize:    dc.w    0
  7735. foreignbitmap:    dc.w    0
  7736.  
  7737. fileaddr:    dc.l    0
  7738. filelen:    dc.l    0
  7739. filememlen:    dc.l    0
  7740. linepos:    dc.l    0
  7741. lines:        dc.l    1
  7742. linelen:    dc.l    notnull
  7743. linelensize:    dc.l    0
  7744.  
  7745. barheight:    dc.l    0    ;linjer att hoppa innan menyraden är slut
  7746. bwidth:        dc.l    0    ;vidd i bytes
  7747.  
  7748. pwidth:        dc.l    0    ;vidd i pixels
  7749. cwidth:        dc.l    0    ;kolumner (tecken)
  7750. cwidthp:    dc.l    0    ;kolumner (pixels)
  7751.  
  7752. pheight:    dc.l    0    ;höjd i pixels
  7753. cheight:    dc.l    0    ;rader (tecken)
  7754. cheightp:    dc.l    0    ;rader (pixels)
  7755.  
  7756. plane0:        dc.l    0
  7757. radpos:        dc.l    0
  7758.  
  7759. null:        dc.l    0
  7760. notnull:    dc.l    -1
  7761.  
  7762. thistask:    dc.l    0
  7763. ;slave:        dc.l    0
  7764. ;printerslave:    dc.l    0
  7765.  
  7766. aslname:    dc.b    "asl.library",0
  7767. diskfontname:    DISKFONTNAME
  7768. dosname:    DOSNAME
  7769. gadtoolsname:    dc.b    "gadtools.library",0
  7770. gfxname:    GRAPHICSNAME
  7771. iconname:    ICONNAME
  7772. intuiname:    INTNAME
  7773. ppname:        PPNAME
  7774. utilname:    UTILITYNAME
  7775. wbname:        WORKBENCHNAME
  7776. xpkname:    XPKNAME
  7777.  
  7778. aslbase:    dc.l    0
  7779. _SysBase:    dc.l    0
  7780. diskfontbase:    dc.l    0
  7781. dosbase:    dc.l    0
  7782. _GfxBase:
  7783. gfxbase:    dc.l    0
  7784. _GadToolsBase:
  7785. gtbase:        dc.l    0
  7786. iconbase:    dc.l    0
  7787. _IntuitionBase:
  7788. intuibase:    dc.l    0
  7789. ppbase:        dc.l    0
  7790. _UtilityBase:
  7791. utilbase:    dc.l    0
  7792. wbbase:        dc.l    0
  7793. xpkbase:    dc.l    0
  7794.  
  7795.  
  7796.  
  7797. unit:        dc.l    0
  7798.  
  7799.  
  7800. filereqptr:    dc.l    0
  7801. setfreqptr:    dc.l    0
  7802. setreqptr:    dc.l    0
  7803.  
  7804. screenptr:    dc.l    0
  7805. screenvi:    dc.l    0
  7806. windowptr:    dc.l    0
  7807. winmenuptr:    dc.l    0
  7808. myfont:        dc.l    0
  7809. fontx:        dc.l    0
  7810. fonty:        dc.l    0
  7811.  
  7812. defreqscreen:    dc.l    0
  7813. status:        dc.b    0
  7814.     even
  7815. tag_done:    dc.l    TAG_DONE
  7816.  
  7817. screentags:
  7818.     dc.l    SA_Depth,2
  7819.     dc.l    SA_Title,screenname
  7820.     dc.l    SA_DisplayID
  7821. displayid:
  7822.     dc.l    HIRES_KEY
  7823.     dc.l    SA_Overscan,OSCAN_TEXT
  7824.     dc.l    SA_AutoScroll,TRUE
  7825.     dc.l    SA_Pens,notnull
  7826.     dc.l    SA_Behind,TRUE
  7827.     dc.l    SA_ErrorCode,screenerrorcode
  7828.     dc.l    SA_SysFont
  7829. scrnsysfont:
  7830.     dc.l    TRUE
  7831.     dc.l    SA_MinimizeISG,TRUE
  7832.     dc.l    TAG_DONE
  7833. screenerrorcode:
  7834.     dc.l    0
  7835.  
  7836. windowtags:
  7837.     dc.l    WA_RptQueue,1
  7838.     dc.l    WA_Left,0
  7839.     dc.l    WA_Top,0
  7840.     dc.l    WA_Width
  7841. windowwidth:
  7842.     dc.l    640
  7843.     dc.l    WA_Height
  7844. windowheight:
  7845.     dc.l    200
  7846.     dc.l    WA_Title,programname
  7847.     dc.l    WA_CustomScreen
  7848. windowonscreen:
  7849.     dc.l    0
  7850.     dc.l    WA_Backdrop,TRUE
  7851.     dc.l    WA_Borderless,TRUE
  7852.     dc.l    WA_ScreenTitle,screentitle
  7853.     dc.l    WA_SmartRefresh,TRUE
  7854.     dc.l    WA_Activate,TRUE
  7855.     dc.l    WA_IDCMP,IDCMP_INACTIVEWINDOW!IDCMP_MOUSEBUTTONS!IDCMP_MENUVERIFY!IDCMP_MOUSEBUTTONS!ARROWIDCMP!SCROLLERIDCMP!IDCMP_REFRESHWINDOW!IDCMP_MENUPICK!IDCMP_VANILLAKEY!IDCMP_RAWKEY
  7856.     ;se även rutinen "printhelp!!"
  7857.  
  7858.     dc.l    WA_NewLookMenus,TRUE
  7859.     dc.l    TAG_DONE
  7860.  
  7861. winmenutags:
  7862.     dc.l    GTMN_FullMenu,NULL
  7863.     dc.l    GTMN_SecondaryError,winmenuerrorcode
  7864.     dc.l    TAG_DONE
  7865. winmenuerrorcode:
  7866.     dc.l    0
  7867.  
  7868.  
  7869. programname:    dc.b    "Textread",0    ;MUST NOT CHANGE! (used as name for messageport)
  7870. filename:    ds.b    32
  7871.     even
  7872.  
  7873. ;fixa winmenu om man inte kör V39+
  7874. fixwinmenu:
  7875.     base    exec
  7876.     cmp.w    #39,LIB_VERSION(a6)
  7877.     bhs.b    .finished
  7878.     lea    winmenu(pc),a0
  7879. .nextnewmenu
  7880.     cmp.b    #NM_END,gnm_Type(a0)
  7881.     beq.b    .finished
  7882.     move.w    gnm_Flags(a0),d0
  7883.     and.w    #NM_COMMANDSTRING,d0
  7884.     beq.b    .ok
  7885.     and.w    #~NM_COMMANDSTRING,gnm_Flags(a0)
  7886.     clr.l    gnm_CommKey(a0)
  7887. .ok
  7888.     add.w    #gnm_SIZEOF,a0
  7889.     bra.b    .nextnewmenu
  7890. .finished
  7891.     rts
  7892.  
  7893. winmenu:
  7894. * Project
  7895.     dc.b    NM_TITLE,0
  7896.     dc.l    .project
  7897.     dc.l    NULL
  7898.     dc.w    0
  7899.     dc.l    0
  7900.     dc.l    NULL
  7901.  
  7902.     dc.b    NM_ITEM,0
  7903.     dc.l    .new
  7904.     dc.l    .newc
  7905.     dc.w    0
  7906.     dc.l    0
  7907.     dc.l    mnew
  7908.  
  7909.     dc.b    NM_ITEM,0
  7910.     dc.l    .open
  7911.     dc.l    .openc
  7912.     dc.w    0
  7913.     dc.l    0
  7914.     dc.l    mopen
  7915.  
  7916.     dc.b    NM_ITEM,0
  7917.     dc.l    .opennew
  7918.     dc.l    NULL
  7919.     dc.w    0
  7920.     dc.l    0
  7921.     dc.l    mopennew
  7922.  
  7923. * -----
  7924.     dc.b    NM_ITEM,0
  7925.     dc.l    NM_BARLABEL
  7926.     dc.l    NULL
  7927.     dc.w    0
  7928.     dc.l    0
  7929.     dc.l    NULL
  7930.  
  7931.     dc.b    NM_ITEM,0
  7932.     dc.l    .save
  7933.     dc.l    .savec
  7934.     dc.w    0
  7935.     dc.l    0
  7936.     dc.l    msave
  7937.  
  7938.     dc.b    NM_ITEM,0
  7939.     dc.l    .saveas
  7940.     dc.l    .saveasc
  7941.     dc.w    0
  7942.     dc.l    0
  7943.     dc.l    msaveas
  7944. * -----
  7945.     dc.b    NM_ITEM,0
  7946.     dc.l    NM_BARLABEL
  7947.     dc.l    NULL
  7948.     dc.w    0
  7949.     dc.l    0
  7950.     dc.l    NULL
  7951.  
  7952.     dc.b    NM_ITEM,0
  7953.     dc.l    .print
  7954.     dc.l    .printc
  7955.     dc.w    0
  7956.     dc.l    0
  7957.     dc.l    mprint
  7958.  
  7959.     dc.b    NM_ITEM,0
  7960.     dc.l    .printas
  7961.     dc.l    NULL
  7962.     dc.w    0
  7963.     dc.l    0
  7964.     dc.l    mprintas
  7965. * -----
  7966.     dc.b    NM_ITEM,0
  7967.     dc.l    NM_BARLABEL
  7968.     dc.l    NULL
  7969.     dc.w    0
  7970.     dc.l    0
  7971.     dc.l    NULL
  7972.  
  7973.     dc.b    NM_ITEM,0
  7974.     dc.l    .reveal
  7975.     dc.l    .revealc
  7976.     dc.w    0
  7977.     dc.l    0
  7978.     dc.l    mreveal
  7979.  
  7980.     dc.b    NM_ITEM,0
  7981.     dc.l    .close
  7982.     dc.l    .closec
  7983.     dc.w    NM_COMMANDSTRING
  7984.     dc.l    0
  7985.     dc.l    mclose
  7986.  
  7987. * -----
  7988.     dc.b    NM_ITEM,0
  7989.     dc.l    NM_BARLABEL
  7990.     dc.l    NULL
  7991.     dc.w    0
  7992.     dc.l    0
  7993.     dc.l    NULL
  7994.  
  7995.     dc.b    NM_ITEM,0
  7996.     dc.l    .iconify
  7997.     dc.l    .iconifyc
  7998.     dc.w    0
  7999.     dc.l    0
  8000.     dc.l    miconify
  8001.  
  8002.     dc.b    NM_ITEM,0
  8003.     dc.l    .workbench
  8004.     dc.l    NULL
  8005.     dc.w    0
  8006.     dc.l    0
  8007.     dc.l    NULL
  8008.  
  8009.     dc.b    NM_SUB,0
  8010.     dc.l    .openwb
  8011.     dc.l    NULL
  8012.     dc.w    0
  8013.     dc.l    0
  8014.     dc.l    mopenwb
  8015.  
  8016.     dc.b    NM_SUB,0
  8017.     dc.l    .closewb
  8018.     dc.l    NULL
  8019.     dc.w    0
  8020.     dc.l    0
  8021.     dc.l    mclosewb
  8022.  
  8023. * -----
  8024.     dc.b    NM_ITEM,0
  8025.     dc.l    NM_BARLABEL
  8026.     dc.l    NULL
  8027.     dc.w    0
  8028.     dc.l    0
  8029.     dc.l    NULL
  8030.  
  8031.     dc.b    NM_ITEM,0
  8032.     dc.l    .about
  8033.     dc.l    .aboutc
  8034.     dc.w    0
  8035.     dc.l    0
  8036.     dc.l    mabout
  8037.  
  8038. * -----
  8039.     dc.b    NM_ITEM,0
  8040.     dc.l    NM_BARLABEL
  8041.     dc.l    NULL
  8042.     dc.w    0
  8043.     dc.l    0
  8044.     dc.l    NULL
  8045.  
  8046.     dc.b    NM_ITEM,0
  8047.     dc.l    .quit
  8048.     dc.l    .quitc
  8049.     dc.w    0
  8050.     dc.l    0
  8051.     dc.l    mquit
  8052.  
  8053. * Settings
  8054.     dc.b    NM_TITLE,0
  8055.     dc.l    .settings
  8056.     dc.l    NULL
  8057.     dc.w    0
  8058.     dc.l    0
  8059.     dc.l    NULL
  8060.  
  8061.     dc.b    NM_ITEM,0
  8062.     dc.l    .wordwrap
  8063.     dc.l    .wordwrapc
  8064.     dc.w    CHECKIT!MENUTOGGLE!CHECKED!NM_COMMANDSTRING
  8065.     dc.l    0
  8066.     dc.l    mwordwrap
  8067.  
  8068.     dc.b    NM_ITEM,0
  8069.     dc.l    .sysfont
  8070.     dc.l    NULL
  8071.     dc.w    CHECKIT!MENUTOGGLE!CHECKED
  8072.     dc.l    0
  8073.     dc.l    msysfont
  8074.  
  8075.     dc.b    NM_ITEM,0
  8076.     dc.l    .alwaysremansi
  8077.     dc.l    NULL
  8078.     dc.w    CHECKIT!MENUTOGGLE!CHECKED
  8079.     dc.l    0
  8080.     dc.l    malwaysremansi
  8081.  
  8082.     dc.b    NM_ITEM,0
  8083.     dc.l    .alwaysremcr
  8084.     dc.l    NULL
  8085.     dc.w    CHECKIT!MENUTOGGLE!CHECKED
  8086.     dc.l    0
  8087.     dc.l    malwaysremcr
  8088.  
  8089.     dc.b    NM_ITEM,0
  8090.     dc.l    .nofontfake
  8091.     dc.l    NULL
  8092.     dc.w    CHECKIT!MENUTOGGLE!CHECKED
  8093.     dc.l    0
  8094.     dc.l    mnofontfake
  8095.  
  8096.     dc.b    NM_ITEM,0
  8097.     dc.l    .legalprint
  8098.     dc.l    NULL
  8099.     dc.w    CHECKIT!MENUTOGGLE!CHECKED
  8100.     dc.l    0
  8101.     dc.l    mlegalprint
  8102.  
  8103. * -----
  8104.     dc.b    NM_ITEM,0
  8105.     dc.l    NM_BARLABEL
  8106.     dc.l    NULL
  8107.     dc.w    0
  8108.     dc.l    0
  8109.     dc.l    NULL
  8110.  
  8111.     dc.b    NM_ITEM,0
  8112.     dc.l    .tabsize
  8113.     dc.l    .tabsizec
  8114.     dc.w    NM_COMMANDSTRING
  8115.     dc.l    0
  8116.     dc.l    mtabsize
  8117.  
  8118.     dc.b    NM_ITEM,0
  8119.     dc.l    .screen
  8120.     dc.l    NULL
  8121.     dc.w    0
  8122.     dc.l    0
  8123.     dc.l    mscreen
  8124.  
  8125.     dc.b    NM_ITEM,0
  8126.     dc.l    .colour
  8127.     dc.l    NULL
  8128.     dc.w    0
  8129.     dc.l    0
  8130.     dc.l    NULL
  8131.  
  8132.     dc.b    NM_SUB,0
  8133.     dc.l    .screencol
  8134.     dc.l    NULL
  8135.     dc.w    0
  8136.     dc.l    0
  8137.     dc.l    mscreencol
  8138.  
  8139.     dc.b    NM_SUB,0
  8140.     dc.l    .defcol
  8141.     dc.l    NULL
  8142.     dc.w    0
  8143.     dc.l    0
  8144.     dc.l    mdefcol
  8145.  
  8146.     dc.b    NM_ITEM,0
  8147.     dc.l    .font
  8148.     dc.l    NULL
  8149.     dc.w    0
  8150.     dc.l    0
  8151.     dc.l    NULL
  8152.  
  8153.     dc.b    NM_SUB,0
  8154.     dc.l    .textfont
  8155.     dc.l    NULL
  8156.     dc.w    0
  8157.     dc.l    0
  8158.     dc.l    mtextfont
  8159.  
  8160.     dc.b    NM_SUB,0
  8161.     dc.l    .deffont
  8162.     dc.l    NULL
  8163.     dc.w    0
  8164.     dc.l    0
  8165.     dc.l    mdeffont
  8166.  
  8167. * -----
  8168.     dc.b    NM_ITEM,0
  8169.     dc.l    NM_BARLABEL
  8170.     dc.l    NULL
  8171.     dc.w    0
  8172.     dc.l    0
  8173.     dc.l    NULL
  8174.  
  8175.     dc.b    NM_ITEM,0
  8176.     dc.l    .loadset
  8177.     dc.l    NULL
  8178.     dc.w    0
  8179.     dc.l    0
  8180.     dc.l    mloadset
  8181.  
  8182.     dc.b    NM_ITEM,0
  8183.     dc.l    .saveset
  8184.     dc.l    NULL
  8185.     dc.w    0
  8186.     dc.l    0
  8187.     dc.l    msaveset
  8188.  
  8189.     dc.b    NM_ITEM,0
  8190.     dc.l    .savesetas
  8191.     dc.l    NULL
  8192.     dc.w    0
  8193.     dc.l    0
  8194.     dc.l    msavesetas
  8195.  
  8196. * -----
  8197.     dc.b    NM_ITEM,0
  8198.     dc.l    NM_BARLABEL
  8199.     dc.l    NULL
  8200.     dc.w    0
  8201.     dc.l    0
  8202.     dc.l    NULL
  8203.  
  8204.     dc.b    NM_ITEM,0
  8205.     dc.l    .createicons
  8206.     dc.l    NULL
  8207.     dc.w    CHECKIT!MENUTOGGLE!CHECKED
  8208.     dc.l    0
  8209.     dc.l    mcreateicons
  8210.  
  8211.     dc.b    NM_ITEM,0
  8212.     dc.l    .prefs2all
  8213.     dc.l    NULL
  8214.     dc.w    0
  8215.     dc.l    0
  8216.     dc.l    mprefs2all
  8217.  
  8218. * Commands
  8219.     dc.b    NM_TITLE,0
  8220.     dc.l    .commands
  8221.     dc.l    NULL
  8222.     dc.w    0
  8223.     dc.l    0
  8224.     dc.l    NULL
  8225.  
  8226.     dc.b    NM_ITEM,0
  8227.     dc.l    .searchfor
  8228.     dc.l    .searchforc
  8229.     dc.w    0
  8230.     dc.l    0
  8231.     dc.l    msearch
  8232.  
  8233.     dc.b    NM_ITEM,0
  8234.     dc.l    .searchsnext
  8235.     dc.l    .searchsnextc
  8236.     dc.w    NM_COMMANDSTRING
  8237.     dc.l    0
  8238.     dc.l    msearchnext
  8239.  
  8240.     dc.b    NM_ITEM,0
  8241.     dc.l    .searchsprev
  8242.     dc.l    .searchsprevc
  8243.     dc.w    NM_COMMANDSTRING
  8244.     dc.l    0
  8245.     dc.l    msearchprev
  8246.  
  8247. * -----
  8248.     dc.b    NM_ITEM,0
  8249.     dc.l    NM_BARLABEL
  8250.     dc.l    NULL
  8251.     dc.w    0
  8252.     dc.l    0
  8253.     dc.l    NULL
  8254.  
  8255.     dc.b    NM_ITEM,0
  8256.     dc.l    .gotoline
  8257.     dc.l    .gotolinec
  8258.     dc.w    NM_COMMANDSTRING
  8259.     dc.l    0
  8260.     dc.l    vl
  8261.  
  8262.     dc.b    NM_ITEM,0
  8263.     dc.l    .gotopercent
  8264.     dc.l    .gotopercentc
  8265.     dc.w    NM_COMMANDSTRING
  8266.     dc.l    0
  8267.     dc.l    vg
  8268. * -----
  8269.     dc.b    NM_ITEM,0
  8270.     dc.l    NM_BARLABEL
  8271.     dc.l    NULL
  8272.     dc.w    0
  8273.     dc.l    0
  8274.     dc.l    NULL
  8275.  
  8276.     dc.b    NM_ITEM,0
  8277.     dc.l    .edittext
  8278.     dc.l    .edittextc
  8279.     dc.w    NM_COMMANDSTRING
  8280.     dc.l    0
  8281.     dc.l    medittext
  8282.  
  8283.     dc.b    NM_ITEM,0
  8284.     dc.l    .remansi
  8285.     dc.l    .remansic
  8286.     dc.w    NM_COMMANDSTRING
  8287.     dc.l    0
  8288.     dc.l    mremansi
  8289.  
  8290.     dc.b    NM_ITEM,0
  8291.     dc.l    .remcr
  8292.     dc.l    .remcrc
  8293.     dc.w    NM_COMMANDSTRING
  8294.     dc.l    0
  8295.     dc.l    mremcr
  8296. * END
  8297.     dc.b    NM_END,0
  8298.     dc.l    0
  8299.     dc.l    NULL
  8300.     dc.w    0
  8301.     dc.l    0
  8302.     dc.l    NULL
  8303.  
  8304. .project    dc.b    "Project",0
  8305. .new        dc.b        "New",0
  8306. .open        dc.b        "Open...",0
  8307. .opennew    dc.b        "Open new...",0
  8308. .save        dc.b        "Save...",0
  8309. .saveas        dc.b        "Save As...",0
  8310. .print        dc.b        "Print",0
  8311. .printas    dc.b        "Print as...",0
  8312. .iconify    dc.b        "Iconify",0
  8313. .workbench    dc.b        "Workbench",0
  8314. .openwb        dc.b            "Open",0
  8315. .closewb    dc.b            "Close",0
  8316. .reveal        dc.b        "Reveal...",0
  8317. .close        dc.b        "Close",0
  8318. .about        dc.b        "About...",0
  8319. .quit        dc.b        "Quit Textread",0
  8320. .settings    dc.b    "Settings",0
  8321. .wordwrap    dc.b        "Wrap words?",0
  8322. .sysfont    dc.b        "Use Sysfont?",0
  8323. .alwaysremansi    dc.b        "Auto-remove ANSIs?",0
  8324. .alwaysremcr    dc.b        "Auto-remove CRs?",0
  8325. .nofontfake    dc.b        "Don't 'fake' font?",0
  8326. .legalprint    dc.b        "System rendering?",0
  8327. .tabsize    dc.b        "Tab size...",0
  8328. .screen         dc.b        "Screen mode...",0
  8329. .colour        dc.b        "Screen colour",0
  8330. .screencol    dc.b            "Select screen colour...",0
  8331. .defcol        dc.b            "Default colour",0
  8332. .font        dc.b        "Text font",0
  8333. .textfont    dc.b            "Select text font...",0
  8334. .deffont    dc.b            "Default font",0
  8335. .loadset    dc.b        "Load settings...",0
  8336. .saveset    dc.b        "Save settings",0
  8337. .savesetas    dc.b        "Save settings as...",0
  8338. .createicons    dc.b        "Create icons?",0
  8339. .prefs2all    dc.b        "Copy to all buffers",0
  8340. .commands    dc.b    "Commands",0
  8341. .searchfor    dc.b        "Find...",0
  8342. .searchsnext    dc.b        "Find next",0
  8343. .searchsprev    dc.b        "Find previous",0
  8344. .gotoline    dc.b        "Go to line",0
  8345. .gotopercent    dc.b        "Go to percent",0
  8346. .edittext    dc.b        "Edit text",0
  8347. .remansi    dc.b        "Remove ANSIs",0
  8348. .remcr        dc.b        "Remove CRs",0
  8349.  
  8350. .newc        dc.b    "N",0
  8351. .openc        dc.b    "O",0
  8352. .savec        dc.b    "S",0
  8353. .saveasc    dc.b    "A",0
  8354. .printc        dc.b    "P",0
  8355. .revealc    dc.b    "R",0
  8356. .closec        dc.b    "Esc",0
  8357. .iconifyc    dc.b    "I",0
  8358. .aboutc        dc.b    "?",0
  8359. .quitc        dc.b    "Q",0
  8360.  
  8361. .wordwrapc    dc.b    "W",0
  8362. .tabsizec    dc.b    "Tab",0
  8363.  
  8364. .searchforc    dc.b    "F",0
  8365. .searchsnextc    dc.b    "N",0
  8366. .searchsprevc    dc.b    "P",0
  8367. .gotolinec    dc.b    "#/L",0
  8368. .gotopercentc    dc.b    "%/G",0
  8369. .edittextc    dc.b    "Shift E",0
  8370. .remansic    dc.b    "Shift A",0
  8371. .remcrc        dc.b    "Shift C",0
  8372.     even
  8373.  
  8374. ***
  8375. ;;
  8376. settings:
  8377.  
  8378. filereqdir:        dc.b    "SYS:",0
  8379.             blk.b    256-(*-filereqdir),0
  8380. filereqpat:        dc.b    "~(#?.info)",0
  8381.             blk.b    64-(*-filereqpat),0
  8382. clcwidth:        dc.l    0        ;countlines' cwidth
  8383.  
  8384. prefs2all_start:
  8385. prefs2all_offset    =prefs2all_start-settings
  8386.  
  8387. thisfont:        dc.l    thisfontname
  8388. thisfontsize:        dc.w    8
  8389.             dc.b    0,FPF_ROMFONT!FPF_DESIGNED
  8390. thisfontname:        dc.b    "topaz.font",0
  8391.             blk.b    31-(*-thisfontname),0
  8392.  
  8393.         even
  8394.  
  8395. tabsize:        dc.l    8
  8396.  
  8397. * --- Checkmarks ---
  8398. setcreateicons:        dc.w    1
  8399. setwordwrap:        dc.w    1
  8400. setsysfont:        dc.w    0
  8401. setalwaysremansi:    dc.w    0
  8402. setalwaysremcr:     dc.w    0
  8403. setnofontfake:        dc.w    1
  8404. setlegalprint:        dc.w    1
  8405.  
  8406.  
  8407. setdisplayid:        dc.l    HIRES_KEY
  8408.  
  8409. palette:
  8410.             dc.l    $AAAAAAAA,$AAAAAAAA,$AAAAAAAA
  8411.             dc.l    $00000000,$00000000,$00000000
  8412.             dc.l    $FFFFFFFF,$FFFFFFFF,$FFFFFFFF
  8413.             dc.l    $66666666,$88888888,$BBBBBBBB
  8414. prefs2all_end:
  8415. prefs2all_len        =prefs2all_end-prefs2all_start
  8416.  
  8417. settings_len        =*-settings
  8418.  
  8419. pol:        dc.l    1
  8420. pom:        dc.l    1
  8421. por:        dc.l    2
  8422. pow:        dc.l    TRUE
  8423. pob:        dc.l    TRUE
  8424. poi:        dc.l    FALSE
  8425. pou:        dc.l    TRUE
  8426. mptab:        dc.l    8
  8427. mppage:        dc.w    0
  8428. mpww:        dc.b    0
  8429. mpinfo:        dc.b    1        ;header on/off
  8430. mpheader:    dc.b    5,1,4,3        ;#0=fet #1=kursiv #2=understr
  8431.                     ;1=filnamn 2=titel 3=sidnummer 4=datum
  8432. mptitle:    blk.b    32,0        ;30 tecken + 1 nolla + jämt!
  8433.  
  8434. defsetname:    dc.b    "ENVARC:Textread/Textread.prefs",0
  8435.     even
  8436.  
  8437.  
  8438. **** muti-buffer structure
  8439.  
  8440.     RSRESET
  8441.     rs.b        LN_SIZE        ;node
  8442. buff_commessageport:    rs.l    1
  8443. buff_fileaddr:        rs.l    1
  8444. buff_filelen:        rs.l    1
  8445. buff_filememlen:    rs.l    1
  8446. buff_linepos:        rs.l    1
  8447. buff_lines:        rs.l    1
  8448. buff_linelen:        rs.l    1
  8449. buff_linelensize:    rs.l    1
  8450. buff_number        rs.b    4    ; 'xx: ', requestreveal uses it!
  8451. buff_filename:        rs.b    32
  8452. buff_setname:        rs.b    setnamelen
  8453. buff_settings:        rs.b    settings_len
  8454. buff_fkeys:        rs.b    fkeys_lines_size
  8455. buff_len:        rs.b    0
  8456.  
  8457.     section Icons,data_c
  8458.  
  8459. AppIconData1:
  8460. ;Plane 0
  8461.     dc.w    $0000,$0000,$0000,$0400,$0000,$0000,$0000,$0C00
  8462.     dc.w    $0000,$0000,$0000,$0C00,$007F,$FFFF,$FFF0,$0C00
  8463.     dc.w    $006A,$AFFE,$AAB0,$0C00,$0040,$0198,$0010,$0C00
  8464.     dc.w    $0040,$07FF,$8010,$0C00,$0040,$7801,$F810,$0C00
  8465.     dc.w    $0441,$8000,$7E11,$0C00,$0E46,$0001,$8791,$0C00
  8466.     dc.w    $1F46,$0006,$0791,$0C00,$0458,$0018,$01E7,$CC00
  8467.     dc.w    $0458,$0060,$01E3,$8C00,$0458,$0000,$01E1,$0C00
  8468.     dc.w    $0046,$0000,$0790,$0C00,$0046,$0000,$0790,$0C00
  8469.     dc.w    $0041,$8000,$1E10,$0C00,$006A,$F801,$FAB0,$0C00
  8470.     dc.w    $007F,$FFFF,$FFF0,$0C00,$0000,$0000,$0000,$0C00
  8471.     dc.w    $0000,$0000,$0000,$0C00,$7FFF,$FFFF,$FFFF,$FC00
  8472. ;Plane 1
  8473.     dc.w    $FFFF,$FFFF,$FFFF,$F800,$D555,$5555,$5555,$5000
  8474.     dc.w    $D555,$5555,$5555,$5000,$D500,$0000,$0005,$5000
  8475.     dc.w    $D515,$5001,$5545,$5000,$D53F,$FE67,$FFE5,$5000
  8476.     dc.w    $D53F,$F800,$7FE5,$5000,$D53F,$87FE,$07E5,$5000
  8477.     dc.w    $D13E,$7FFF,$E1E4,$5000,$D139,$FFFF,$F864,$5000
  8478.     dc.w    $C039,$FFFF,$F864,$5000,$D127,$FFFF,$FE00,$1000
  8479.     dc.w    $D127,$FF9F,$FE04,$5000,$D127,$FFFF,$FE04,$5000
  8480.     dc.w    $D539,$FFFF,$F865,$5000,$D539,$FFFF,$F865,$5000
  8481.     dc.w    $D53E,$7FFF,$E165,$5000,$D515,$07FE,$0545,$5000
  8482.     dc.w    $D500,$0000,$0005,$5000,$D555,$5555,$5555,$5000
  8483.     dc.w    $D555,$5555,$5555,$5000,$8000,$0000,$0000,$0000
  8484.  
  8485. AppIcon1:
  8486.     dc.w    0,0
  8487.     dc.w    54,22,2
  8488.     dc.l    AppIconData1
  8489.     dc.b    3,0
  8490.     dc.l    NULL
  8491.  
  8492. AppIconData2:
  8493. ;Plane 0
  8494.     dc.w    $FFFF,$FFFF,$FFFF,$F800,$C000,$0000,$0000,$0000
  8495.     dc.w    $C000,$0000,$0000,$0000,$C07F,$FFFF,$FFF0,$0000
  8496.     dc.w    $C06A,$AFFE,$AAB0,$0000,$C040,$0018,$0010,$0000
  8497.     dc.w    $C45D,$D5DF,$8011,$0000,$CE49,$1481,$F011,$0000
  8498.     dc.w    $DF49,$8880,$0091,$0000,$C449,$1480,$1897,$C000
  8499.     dc.w    $C449,$D480,$9493,$8000,$CE40,$001D,$5431,$0000
  8500.     dc.w    $DF58,$0191,$D4B1,$0000,$C458,$0159,$5877,$C000
  8501.     dc.w    $C446,$0191,$4793,$8000,$C446,$015C,$0791,$0000
  8502.     dc.w    $C041,$8140,$1E10,$0000,$C06A,$F801,$FAB0,$0000
  8503.     dc.w    $C07F,$FFFF,$FFF0,$0000,$C000,$0000,$0000,$0000
  8504.     dc.w    $C000,$0000,$0000,$0000,$8000,$0000,$0000,$0000
  8505. ;Plane 1
  8506.     dc.w    $0000,$0000,$0000,$0400,$2AAA,$AAAA,$AAAA,$AC00
  8507.     dc.w    $2AAA,$AAAA,$AAAA,$AC00,$2A80,$0000,$000A,$AC00
  8508.     dc.w    $2A95,$5001,$554A,$AC00,$2ABF,$FFE7,$FFEA,$AC00
  8509.     dc.w    $2AA2,$2A20,$7FEA,$AC00,$20B6,$EB7E,$0FEA,$AC00
  8510.     dc.w    $20B6,$777F,$FF6A,$AC00,$2AB6,$EB7F,$E768,$2C00
  8511.     dc.w    $2AB6,$2B7F,$6B68,$2C00,$20BF,$FFE2,$ABCA,$AC00
  8512.     dc.w    $20A7,$FE6E,$2B4A,$AC00,$2AA7,$FEA6,$A788,$2C00
  8513.     dc.w    $2AB9,$FE6E,$B868,$2C00,$2AB9,$FEA3,$F86A,$AC00
  8514.     dc.w    $2ABE,$7EBF,$E1EA,$AC00,$2A95,$07FE,$054A,$AC00
  8515.     dc.w    $2A80,$0000,$000A,$AC00,$2AAA,$AAAA,$AAAA,$AC00
  8516.     dc.w    $2AAA,$AAAA,$AAAA,$AC00,$7FFF,$FFFF,$FFFF,$FC00
  8517.  
  8518. AppIcon2:
  8519.     dc.w    0,0
  8520.     dc.w    54,22,2
  8521.     dc.l    AppIconData2
  8522.     dc.b    3,0
  8523.     dc.l    NULL
  8524.  
  8525. AppIconDO:
  8526.     dc.w    NULL            ; Magic Number
  8527.     dc.w    NULL            ; Version
  8528.                     ; Embedded Gadget Structure
  8529.     dc.l    NULL            ; Next Gadget Pointer
  8530.     dc.w    0,0,54,23        ; Left,Top,Width,Height
  8531.     dc.w    GFLG_GADGHIMAGE        ; Flags
  8532.     dc.w    NULL            ; Activation Flags
  8533.     dc.w    NULL            ; Gadget Type
  8534.     dc.l    AppIcon1        ; Render Image
  8535.     dc.l    AppIcon2        ; Select Image
  8536.     dc.l    NULL            ; Gadget Text
  8537.     dc.l    NULL            ; Mutual Exclude
  8538.     dc.l    NULL            ; Special Info
  8539.     dc.w    NULL            ; Gadget ID
  8540.     dc.l    NULL            ; User Data
  8541.  
  8542.     dc.b    NULL,0    ;WBTOOL t.ex.      Icon Type
  8543.     dc.l    NULL            ; Default Tool
  8544.     dc.l    NULL            ; Tool Type Array
  8545.     dc.l    NO_ICON_POSITION    ; Current X
  8546.     dc.l    NO_ICON_POSITION    ; Current Y
  8547.     dc.l    NULL            ; Drawer Structure
  8548.     dc.l    NULL            ; Tool Window
  8549.     dc.l    NULL            ; Stack size
  8550.  
  8551. Textread_prefsI1Data:
  8552. ;Plane 0
  8553.     dc.w    $0000,$0000,$0004,$0000,$0000,$0000,$0001,$0000
  8554.     dc.w    $0000,$07FF,$8000,$4000,$1DD5,$D800,$6000,$1000
  8555.     dc.w    $0914,$A0FC,$1000,$0800,$0988,$C102,$0800,$0C00
  8556.     dc.w    $0914,$C082,$0800,$0C00,$09D4,$C082,$0800,$0C00
  8557.     dc.w    $0000,$2104,$0800,$0C00,$19C9,$9E18,$1000,$0C00
  8558.     dc.w    $1515,$4060,$2000,$0C00,$199D,$4080,$C000,$0C00
  8559.     dc.w    $1515,$4103,$0000,$0C00,$15D5,$821C,$0000,$0C00
  8560.     dc.w    $0000,$0109,$99DD,$CC00,$0000,$00F1,$5511,$0C00
  8561.     dc.w    $0000,$0109,$9999,$CC00,$0000,$0109,$1510,$4C00
  8562.     dc.w    $4000,$00F1,$15D1,$CC00,$1000,$0000,$0000,$0C00
  8563.     dc.w    $0400,$0000,$0000,$0C00,$01FF,$FFFF,$FFFF,$FC00
  8564. ;Plane 1
  8565.     dc.w    $FFFF,$FFFF,$FFF8,$0000,$D555,$5555,$5556,$0000
  8566.     dc.w    $D555,$5000,$5555,$8000,$C000,$07FF,$9555,$6000
  8567.     dc.w    $C000,$1F03,$E555,$5000,$C000,$3E55,$F555,$5000
  8568.     dc.w    $C000,$3F55,$F555,$5000,$C000,$3F55,$F555,$5000
  8569.     dc.w    $D555,$5E53,$F555,$5000,$C000,$0147,$E555,$5000
  8570.     dc.w    $C000,$151F,$D555,$5000,$C000,$157F,$1555,$5000
  8571.     dc.w    $C000,$14FC,$5555,$5000,$C000,$15E1,$5555,$5000
  8572.     dc.w    $D555,$54F4,$0000,$1000,$D555,$5504,$0000,$1000
  8573.     dc.w    $D555,$54F4,$0000,$1000,$D555,$54F4,$0000,$1000
  8574.     dc.w    $3555,$5504,$0000,$1000,$0D55,$5555,$5555,$5000
  8575.     dc.w    $0355,$5555,$5555,$5000,$0000,$0000,$0000,$0000
  8576.  
  8577. Textread_prefsI1:
  8578.     dc.w    0,0
  8579.     dc.w    54,22,2
  8580.     dc.l    Textread_prefsI1Data
  8581.     dc.b    3,0
  8582.     dc.l    NULL
  8583.  
  8584. Textread_prefsTools:
  8585.     dc.l    .text
  8586.     dc.l    NULL
  8587. .text
  8588.     dc.b    "FILETYPE=PREFS",0
  8589.     even
  8590.  
  8591. Textread_prefs:
  8592.     dc.w    WB_DISKMAGIC
  8593.     dc.w    WB_DISKVERSION
  8594.  
  8595.     dc.l    NULL
  8596.     dc.w    0,0,54,23
  8597.     dc.w    GFLG_GADGIMAGE!GADGBACKFILL
  8598.     dc.w    GACT_RELVERIFY!GADGIMMEDIATE
  8599.     dc.w    BOOLGADGET
  8600.     dc.l    Textread_prefsI1
  8601.     dc.l    NULL
  8602.     dc.l    NULL
  8603.     dc.l    NULL
  8604.     dc.l    NULL
  8605.     dc.w    0
  8606.     dc.l    NULL
  8607.  
  8608.      dc.b    WBPROJECT,0
  8609.     dc.l    .deftool
  8610.     dc.l    Textread_prefsTools
  8611.     dc.l    NO_ICON_POSITION
  8612.     dc.l    NO_ICON_POSITION
  8613.     dc.l    NULL
  8614.     dc.l    NULL
  8615.     dc.l    4096
  8616. .deftool
  8617.     dc.b    "Textread",0
  8618.     even
  8619.  
  8620.     section    bssdata,BSS
  8621.  
  8622. fib        ds.b    fib_SIZEOF    ;fileinfoblock, lw-aligned (splitfilepath:)
  8623. com_array:    ds.b    coma_SIZE
  8624. int:        ds.b    IS_SIZE
  8625. lockwinreq:    ds.b    rq_SIZEOF    ;(lockwindow)
  8626. XPKerrbuf:    ds.b    XPKERRMSGSIZE
  8627. colortable:    ds.l    1+4*3+1        ;(changepalette)
  8628. searchstring:    ds.b    80
  8629. screentitle:    ds.b    90
  8630. savedfont:    ds.b    ta_SIZEOF
  8631. savedfontname:    ds.b    31
  8632. numdec_buffert    ds.b    11
  8633.  
  8634. defpalette:    ds.l    4*3
  8635. setname:    ds.b    setnamelen
  8636. tabbar:        ds.b    256
  8637. printtabbar:    ds.b    256
  8638. argprojectname:    ds.b    256
  8639. temp:        ds.b    512
  8640. tempend:
  8641. tempsize    =*-temp
  8642.  
  8643. oldfontname:    ds.b    32
  8644.  
  8645. font:        ds.b    256*8
  8646.  
  8647.  
  8648. deffont:    ds.b    ta_SIZEOF
  8649. deffontname:    ds.b    31
  8650. prefs_id_test:    ds.b    prefs_id_len+1
  8651.  
  8652.     section windows,code
  8653.  
  8654.  
  8655.  
  8656. HRWv    MACRO        ;character,function
  8657.     dc.w    \1
  8658.     dc.l    \2
  8659.     ENDM
  8660.  
  8661. HRWr    MACRO        ;keycode,qual (or),function
  8662.     dc.w    \1,\2
  8663.     dc.l    \3
  8664.     ENDM
  8665.  
  8666. HRWg    MACRO
  8667.     dc.w    \1
  8668.     dc.l    \2
  8669.     ENDM
  8670.  
  8671. HWRv_SIZEOF    EQU    2+4
  8672. HWRr_SIZEOF    EQU    2+2+4
  8673. HWRg_SIZEOF    EQU    2+4
  8674.  
  8675.     RSRESET
  8676. hrw_window    rs.l    1
  8677. hrw_render    rs.l    1
  8678. hrw_vkeys    rs.l    1
  8679. hrw_rkeys    rs.l    1
  8680. hrw_gadgets    rs.l    1
  8681.  
  8682.  
  8683.  
  8684.  
  8685.  
  8686. ;ut:
  8687. * d0    -1    avsluta Textread
  8688. * d0    0    allt ok, leta inte
  8689. * d0    1    allt ok, leta
  8690. requestsearch:
  8691.  
  8692.     move.l    screenptr,a1
  8693.     bsr    OpenfindreqWindow
  8694.     tst.l    d0
  8695.     bne.w    .error
  8696.     jsr    lockwindow
  8697.  
  8698.     move.w    search_wild,.wild+2
  8699.     move.w    search_case,.casesens+2
  8700.     move.w    search_dir,.dir+2
  8701.  
  8702.     BASE    gt
  8703.     move.l    findreq(pc),a4
  8704.     suba.l    a2,a2
  8705.     move.l    findreqGadgets+GD_sw_searchfor*4(pc),a0
  8706.     move.l    a4,a1
  8707.     lea    .searchfor_tags(pc),a3
  8708.     call    GT_SetGadgetAttrsA
  8709.     move.l    findreqGadgets+GD_sw_casesens*4(pc),a0
  8710.     move.l    a4,a1
  8711.     lea    .casesens_tags(pc),a3
  8712.     call    GT_SetGadgetAttrsA
  8713.     move.l    findreqGadgets+GD_sw_wildcards*4(pc),a0
  8714.     move.l    a4,a1
  8715.     lea    .wildcards_tags(pc),a3
  8716.     call    GT_SetGadgetAttrsA
  8717.     move.l    findreqGadgets+GD_sw_fwdbwd*4(pc),a0
  8718.     move.l    a4,a1
  8719.     lea    .direction_tags(pc),a3
  8720.     call    GT_SetGadgetAttrsA
  8721.  
  8722.     BASE    intui
  8723.     move.l    findreqGadgets+GD_sw_searchfor*4(pc),a0
  8724.     move.l    findreq(pc),a1
  8725.     suba.l    a2,a2
  8726.     call    ActivateGadget
  8727.  
  8728.     lea    .strukt(pc),a0
  8729.     move.l    findreq(pc),(a0)
  8730.     bsr    handlerequestwindow
  8731.     move.l    d0,-(sp)
  8732.     jsr    unlockwindow
  8733.     bsr    ClosefindreqWindow
  8734.     move.l    (sp)+,d0
  8735.     rts
  8736. .error
  8737.     moveq    #0,d0
  8738.     rts
  8739. .strukt
  8740.     dc.l    0
  8741.     dc.l    .render
  8742.     dc.l    .strukt_v
  8743.     dc.l    .strukt_r
  8744.     dc.l    .strukt_g
  8745.  
  8746. .strukt_v
  8747.     HRWv    "s",.fn_search
  8748.     HRWv    $0d,.fn_search
  8749.     HRWv    "u",.fn_use
  8750.     HRWv    "c",.fn_cancel
  8751.     HRWv    $1b,.fn_cancel
  8752.     HRWv    "f",.fn_find
  8753.     HRWv    "w",.fn_wild
  8754.     HRWv    "a",.fn_case
  8755.     HRWv    "d",.fn_dir
  8756.     HRWv    -1,-1
  8757. .strukt_r
  8758.     HRWr    -1,-1,-1
  8759. .strukt_g
  8760.  
  8761.     HRWg    GD_sw_searchfor,.fn_findgad
  8762.     HRWg    GD_sw_wildcards,.fn_wildgad
  8763.     HRWg    GD_sw_casesens,.fn_casegad
  8764.     HRWg    GD_sw_fwdbwd,.fn_dirgad
  8765.     HRWg    GD_sw_search,.fn_searchgad
  8766.     HRWg    GD_sw_use,.fn_usegad
  8767.     HRWg    GD_sw_cancel,.fn_cancelgad
  8768.     HRWg    -1,-1
  8769.  
  8770. .render
  8771. ;    bsr    searchwindowRender
  8772.     rts
  8773.  
  8774. .fn_search
  8775.     move.l    hrw_window(a5),a2
  8776.     move.l    findreqGadgets+GD_sw_search*4(pc),a3
  8777.     jsr    PressButton
  8778. .fn_searchgad
  8779.     bsr.w    .update
  8780.     move.w    #1+1,d0
  8781.     rts
  8782. .fn_use
  8783.     move.l    hrw_window(a5),a2
  8784.     move.l    findreqGadgets+GD_sw_use*4(pc),a3
  8785.     jsr    PressButton
  8786. .fn_usegad
  8787.     bsr.w    .update
  8788.     move.w    #0+1,d0
  8789.     rts
  8790. .fn_cancel
  8791.     move.l    hrw_window(a5),a2
  8792.     move.l    findreqGadgets+GD_sw_cancel*4(pc),a3
  8793.     jsr    PressButton
  8794. .fn_cancelgad
  8795.     move.w    #0+1,d0
  8796.     rts
  8797. .fn_find
  8798.     BASE    intui
  8799.     move.l    findreqGadgets+GD_sw_searchfor*4(pc),a0
  8800.     move.l    findreq(pc),a1
  8801.     suba.l    a2,a2
  8802.     call    ActivateGadget
  8803.     moveq    #0,d0
  8804.     rts
  8805. .fn_findgad
  8806.     and.w    #IEQUALIFIERB_LSHIFT!IEQUALIFIERB_RSHIFT,d4
  8807.     beq.w    .fn_search
  8808.     moveq    #0,d0
  8809.     rts
  8810. .fn_wild
  8811.     bchg    #0,.wild+3
  8812.     move.l    findreqGadgets+GD_sw_wildcards*4(pc),a0
  8813.     move.l    findreq(pc),a1
  8814.     suba.l    a2,a2
  8815.     lea    .wildcards_tags(pc),a3
  8816.     call    GT_SetGadgetAttrsA
  8817.     moveq    #0,d0
  8818.     rts
  8819. .fn_wildgad
  8820.     clr.l    .wild
  8821.     move.w    gg_Flags(a2),d0
  8822.     and.w    #GFLG_SELECTED,d0
  8823.     beq.s    .fn_wildgad_notselected
  8824.     addq.l    #1,.wild
  8825. .fn_wildgad_notselected
  8826.     moveq    #0,d0
  8827.     rts
  8828. .fn_case
  8829.     bchg    #0,.casesens+3
  8830.     move.l    findreqGadgets+GD_sw_casesens*4(pc),a0
  8831.     move.l    findreq(pc),a1
  8832.     suba.l    a2,a2
  8833.     lea    .casesens_tags(pc),a3
  8834.     call    GT_SetGadgetAttrsA
  8835.     moveq    #0,d0
  8836.     rts
  8837. .fn_casegad
  8838.     clr.l    .casesens
  8839.     move.w    gg_Flags(a2),d0
  8840.     and.w    #GFLG_SELECTED,d0
  8841.     beq.s    .fn_casegad_notselected
  8842.     addq.l    #1,.casesens
  8843. .fn_casegad_notselected
  8844.     moveq    #0,d0
  8845.     rts
  8846. .fn_dir
  8847.     bchg    #0,.dir+3
  8848.     move.l    findreqGadgets+GD_sw_fwdbwd*4(pc),a0
  8849.     move.l    findreq(pc),a1
  8850.     suba.l    a2,a2
  8851.     lea    .direction_tags(pc),a3
  8852.     call    GT_SetGadgetAttrsA
  8853.     moveq    #0,d0
  8854.     rts
  8855. .fn_dirgad
  8856.     move.l    d3,.dir
  8857.     moveq    #0,d0
  8858.     rts
  8859.  
  8860. .update
  8861.     move.w    .wild+2,search_wild
  8862.     move.w    .casesens+2,search_case
  8863.     move.w    .dir+2,search_dir
  8864.     move.l    findreqGadgets+GD_sw_searchfor*4(pc),a0
  8865.     move.l    gg_SpecialInfo(a0),a0
  8866.     move.l    si_Buffer(a0),a0
  8867.     moveq    #79,d0
  8868.     lea    searchstring,a1
  8869. .fn_use_copy
  8870.     move.b    (a0)+,(a1)+
  8871.     dbeq    d0,.fn_use_copy
  8872.     rts
  8873.     
  8874. .searchfor_tags
  8875.     dc.l    GTST_String,searchstring
  8876.     dc.l    TAG_DONE
  8877. .casesens_tags
  8878.     dc.l    GTCB_Checked
  8879. .casesens
  8880.     dc.l    0            ;1=japps
  8881.     dc.l    TAG_DONE
  8882. .wildcards_tags
  8883.     dc.l    GTCB_Checked
  8884. .wild
  8885.     dc.l    0            ;1=wildcards on
  8886.     dc.l    TAG_DONE
  8887. .direction_tags
  8888.     dc.l    GTCY_Active
  8889. .dir
  8890.     dc.l    0            ;1=backwards
  8891.     dc.l    TAG_DONE
  8892.  
  8893. ;ut:
  8894. * d0    -1    avsluta Textread
  8895. * d0    0    allt ok, byt inte
  8896. * d0    1    allt ok, byt
  8897. requesttabsize:
  8898.     move.l    screenptr,a1
  8899.     bsr    OpentabsizereqWindow
  8900.     tst.l    d0
  8901.     bne.b    .error
  8902.     jsr    lockwindow
  8903.  
  8904.     move.l    tabsize,.level
  8905.     bsr    .uppdateraslidern
  8906.  
  8907.  
  8908.     lea    .strukt(pc),a0
  8909.     move.l    tabsizereq(pc),(a0)
  8910.     bsr    handlerequestwindow
  8911.     move.l    d0,-(sp)
  8912.     jsr    unlockwindow
  8913.     bsr    ClosetabsizereqWindow
  8914.     move.l    (sp)+,d0
  8915.     rts
  8916. .error
  8917.     moveq    #0,d0
  8918.     rts
  8919.  
  8920. .strukt
  8921.     dc.l    0
  8922.     dc.l    .render
  8923.     dc.l    .strukt_v
  8924.     dc.l    .strukt_r
  8925.     dc.l    .strukt_g
  8926.  
  8927. .strukt_v
  8928.     HRWv    "u",.fn_use
  8929.     HRWv    $0d,.fn_use
  8930.     HRWv    "c",.fn_cancel
  8931.     HRWv    $1b,.fn_cancel
  8932.     HRWv    "t",.fn_inc
  8933.     HRWv    "T",.fn_dec
  8934.     HRWv    -1,-1
  8935. .strukt_r
  8936.     HRWr    IEQUALIFIER_LSHIFT!IEQUALIFIER_RSHIFT,$4f,.fn_first
  8937.     HRWr    0,$4f,.fn_dec
  8938.     HRWr    IEQUALIFIER_LSHIFT!IEQUALIFIER_RSHIFT,$4e,.fn_last
  8939.     HRWr    0,$4e,.fn_inc
  8940.     HRWr    0,$4c,.fn_center
  8941.     HRWr    -1,-1,-1
  8942. .strukt_g
  8943.     HRWg    GD_tw_use,.fn_usegad
  8944.     HRWg    GD_tw_cancel,.fn_cancelgad
  8945.     HRWg    GD_tw_tabsize,.fn_slider
  8946.     HRWg    -1,-1
  8947.  
  8948. .render
  8949. ;    bsr    tabsizereqRender
  8950.     rts
  8951.  
  8952. .fn_use
  8953.     move.l    hrw_window(a5),a2
  8954.     move.l    tabsizereqGadgets+GD_tw_use*4(pc),a3
  8955.     jsr    PressButton
  8956. .fn_usegad
  8957.     move.l    .level,tabsize
  8958.     moveq    #1+1,d0
  8959.     rts
  8960. .fn_cancel
  8961.     move.l    hrw_window(a5),a2
  8962.     move.l    tabsizereqGadgets+GD_tw_cancel*4(pc),a3
  8963.     jsr    PressButton
  8964. .fn_cancelgad
  8965.     moveq    #0+1,d0
  8966.     rts
  8967. .fn_dec
  8968.     cmp.l    #1,.level
  8969.     beq.b    .fn_dec_first
  8970.     subq.l    #1,.level
  8971. .fn_dec_first
  8972.     bra.b    .uppdateraslidern
  8973. .fn_inc
  8974.     cmp.l    #15,.level
  8975.     beq.b    .fn_inc_last
  8976.     addq.l    #1,.level
  8977. .fn_inc_last
  8978.     bra.b    .uppdateraslidern
  8979. .fn_first
  8980.     move.l    #1,.level
  8981.     bra.b    .uppdateraslidern
  8982. .fn_last
  8983.     move.l    #15,.level
  8984.     bra.b    .uppdateraslidern
  8985. .fn_center
  8986.     move.l    #8,.level
  8987.     bra.w    .uppdateraslidern
  8988. .fn_slider
  8989.     move.l    d3,.level
  8990.     moveq    #0,d0
  8991.     rts
  8992. .uppdateraslidern
  8993.     BASE    gt
  8994.     move.l    tabsizereqGadgets+GD_tw_tabsize*4(pc),a0
  8995.     move.l    tabsizereq(pc),a1
  8996.     suba.l    a2,a2
  8997.     lea    .upp_tabsize_level(pc),a3
  8998.     call    GT_SetGadgetAttrsA
  8999.     moveq    #0,d0
  9000.     rts
  9001.  
  9002. .upp_tabsize_level
  9003.     dc.l    GTSL_Level
  9004. .level    dc.l    0
  9005.     dc.l    TAG_DONE
  9006.  
  9007.  
  9008. ;ut:
  9009. * d0    -1    avsluta Textread
  9010. * d0    0    allt ok, byt inte
  9011. * d0    1    allt ok, byt
  9012. requestreveal:
  9013.     lea    bufflist,a1        ;update buffer numbers ('xx: filename')
  9014.     moveq    #1,d1
  9015. .stepdown
  9016.     TSTNODE    a1,a1
  9017.     beq.b    .listok
  9018.     move.l    d1,d0
  9019.     addq.l    #1,d1
  9020.     jsr    numdec
  9021.     lea    buff_number(a1),a2
  9022.     move.b    8(a0),(a2)+
  9023.     move.b    9(a0),(a2)+
  9024.     move.b    #":",(a2)+
  9025.     move.b    #" ",(a2)+
  9026.     bra.b    .stepdown
  9027. .listok
  9028.  
  9029.     move.l    screenptr,a1
  9030.     bsr    OpenrevealreqWindow
  9031.     tst.l    d0
  9032.     bne.b    .error
  9033.     jsr    lockwindow
  9034.  
  9035.     BASE    gt
  9036.     move.l    revealreqGadgets+GD_rw_list*4(pc),a0
  9037.     move.l    revealreq(pc),a1
  9038.     suba.l    a2,a2
  9039.     lea    .initlist_tags(pc),a3
  9040.     call    GT_SetGadgetAttrsA
  9041.  
  9042.     move.l    bnum,.selected
  9043.     subq.l    #1,.selected
  9044.     bsr    .uppdateralistan
  9045.  
  9046.     lea    .strukt(pc),a0
  9047.     move.l    revealreq(pc),(a0)
  9048.     bsr    handlerequestwindow
  9049.     move.l    d0,-(sp)
  9050.     jsr    unlockwindow
  9051.     bsr    CloserevealreqWindow
  9052.     move.l    (sp)+,d0
  9053.     rts
  9054. .error
  9055.     moveq    #0,d0
  9056.     rts
  9057. .initlist_tags
  9058.     dc.l    GTLV_Labels,bufflist
  9059.     dc.l    TAG_DONE
  9060. .strukt
  9061.     dc.l    0
  9062.     dc.l    .render
  9063.     dc.l    .strukt_v
  9064.     dc.l    .strukt_r
  9065.     dc.l    .strukt_g
  9066.  
  9067. .strukt_v
  9068.     HRWv    "u",.fn_use
  9069.     HRWv    $0d,.fn_use
  9070.     HRWv    "c",.fn_cancel
  9071.     HRWv    $1b,.fn_cancel
  9072.     HRWv    "b",.fn_next
  9073.     HRWv    "B",.fn_prev
  9074.     HRWv    -1,-1
  9075. .strukt_r
  9076.     HRWr    IEQUALIFIER_LSHIFT!IEQUALIFIER_RSHIFT,$4c,.fn_top
  9077.     HRWr    0,$4c,.fn_prev
  9078.     HRWr    IEQUALIFIER_LSHIFT!IEQUALIFIER_RSHIFT,$4d,.fn_end
  9079.     HRWr    0,$4d,.fn_next
  9080.     HRWr    -1,-1,-1
  9081. .strukt_g
  9082.  
  9083.     HRWg    GD_rw_list,.fn_list
  9084.     HRWg    GD_rw_use,.fn_usegad
  9085.     HRWg    GD_rw_cancel,.fn_cancelgad
  9086.     HRWg    -1,-1
  9087.  
  9088. .render
  9089.     rts
  9090.  
  9091. .fn_use
  9092.     move.l    hrw_window(a5),a2
  9093.     move.l    revealreqGadgets+GD_rw_use*4(pc),a3
  9094.     jsr    PressButton
  9095. .fn_usegad
  9096.     move.l    .selected,bnum
  9097.     addq.l    #1,bnum
  9098.     move.w    #1+1,d0
  9099.     rts
  9100. .fn_cancel
  9101.     move.l    hrw_window(a5),a2
  9102.     move.l    revealreqGadgets+GD_rw_cancel*4(pc),a3
  9103.     jsr    PressButton
  9104. .fn_cancelgad
  9105.     move.w    #0+1,d0
  9106.     rts
  9107. .fn_next
  9108.     move.l    bmax,d0
  9109.     subq.l    #1,d0
  9110.     cmp.l    .selected,d0
  9111.     beq.b    .fn_next_last
  9112.     addq.l    #1,.selected
  9113. .fn_next_last
  9114.     bra.w    .uppdateralistan
  9115. .fn_prev
  9116.     tst.l    .selected
  9117.     beq.b    .fn_prev_first
  9118.     subq.l    #1,.selected
  9119. .fn_prev_first
  9120.     bra.w    .uppdateralistan
  9121. .fn_top
  9122.     clr.l    .selected
  9123.     bra.w    .uppdateralistan
  9124. .fn_end
  9125.     move.l    bmax,.selected
  9126.     subq.l    #1,.selected
  9127.     bra.w    .uppdateralistan
  9128. .fn_list
  9129.     move.l    .fn_list_time(pc),d0
  9130.     move.l    .fn_list_time+4(pc),d1
  9131.     move.l    d5,.fn_list_time
  9132.     move.l    d6,.fn_list_time+4
  9133.  
  9134.     move.l    .selected(pc),d4
  9135.     move.l    d3,.selected
  9136.     cmp.l    .selected(pc),d4
  9137.     bne    .fn_list_exit
  9138.     move.l    d5,d2
  9139.     move.l    d6,d3
  9140.     BASE    intui
  9141.     call    DoubleClick
  9142.     tst.l    d0
  9143.     bne.w    .fn_use
  9144. .fn_list_exit
  9145.     moveq    #0,d0
  9146.     rts
  9147. .fn_list_time
  9148.     dc.l    0,0
  9149.  
  9150. .uppdateralistan
  9151.     BASE    gt
  9152.     cmp.w    #39,LIB_VERSION(a6)
  9153.     bhs.b    .uppdateralistan_selected
  9154. *** Kludge för <V39
  9155.     move.l    .top(pc),d0
  9156.     cmp.l    .selected(pc),d0
  9157.     bmi.b    .uppdateralistan_notB4
  9158.     move.l    .selected(pc),.top
  9159.     bra.b    .uppdateralistan_doit
  9160. .uppdateralistan_notB4
  9161.     addq.l    #6-1,d0                ;?????????? WHERE?? FIXIT!
  9162.     cmp.l    .selected(pc),d0
  9163.     bpl.b    .uppdateralistan_selected
  9164.     move.l    .selected(pc),d0
  9165.     subq.l    #6-1,d0
  9166.     move.l    d0,.top
  9167. .uppdateralistan_doit
  9168.     move.l    revealreqGadgets+GD_rw_list*4(pc),a0
  9169.     move.l    revealreq(pc),a1
  9170.     suba.l    a2,a2
  9171.     lea    .top_tags(pc),a3
  9172.     call    GT_SetGadgetAttrsA
  9173. .uppdateralistan_selected
  9174.     move.l    .selected,.visible
  9175.     move.l    revealreqGadgets+GD_rw_list*4(pc),a0
  9176.     move.l    revealreq(pc),a1
  9177.     suba.l    a2,a2
  9178.     lea    .selected_tags(pc),a3
  9179.     call    GT_SetGadgetAttrsA
  9180.  
  9181.     moveq    #0,d0
  9182.     rts
  9183.  
  9184. .selected_tags
  9185.     dc.l    GTLV_Selected
  9186. .selected
  9187.     dc.l    0
  9188.     dc.l    GTLV_MakeVisible
  9189. .visible
  9190.     dc.l    0
  9191.     dc.l    TAG_DONE
  9192.  
  9193. .top_tags
  9194.     dc.l    GTLV_Top
  9195. .top
  9196.     dc.l    0
  9197.     dc.l    TAG_DONE
  9198.  
  9199. requestprintopts:
  9200.     jsr    lockwindow
  9201.     bsr    printoptions
  9202.     move.l    d0,-(sp)
  9203.     jsr    unlockwindow
  9204.     move.l    (sp)+,d0
  9205.     rts
  9206.  
  9207.  
  9208.  
  9209. ;ut:
  9210. * d0    -1    avsluta Textread
  9211. * d0    0    allt ok, byt inte rad
  9212. * d0    1    allt ok, byt rad
  9213. * d1    tal
  9214. requestpercent:
  9215. .again
  9216.     move.l    linepos,d0
  9217.     mulu.w    #100,d0
  9218.     move.l    lines,d1
  9219.     sub.l    cheight,d1
  9220.     beq.b    .nodiv
  9221.     divu.w    d1,d0
  9222. .nodiv
  9223.     and.l    #$0000ffff,d0
  9224.     lea    .number(pc),a0
  9225.     move.l    d0,(a0)
  9226.     lea    .text1(pc),a1
  9227.     lea    .text2(pc),a2
  9228.  
  9229.     bsr    requestinteger
  9230.  
  9231.     tst.l    d0
  9232.     bmi.b    .exit
  9233.     beq.b    .exit
  9234.  
  9235.     move.l    .number(pc),d1
  9236.  
  9237.     cmp.l    #100,d1
  9238.     bhi.b    .again
  9239.  
  9240. .exit
  9241.     rts
  9242.  
  9243. .text1    dc.b    "Go to %",0
  9244. .text2    dc.b    "Min: 0 -- Max: 100"
  9245. .number    dc.l    0
  9246.  
  9247. ;ut:
  9248. * d0    -1    avsluta Textread
  9249. * d0    0    allt ok, byt inte rad
  9250. * d0    1    allt ok, byt rad
  9251. * d1    tal
  9252. requestline:
  9253. .again
  9254.     move.l    lines,d0
  9255.     sub.l    cheight,d0
  9256.     bpl.b    .ok
  9257.     moveq    #0,d0
  9258. .ok
  9259.     lea    .max(pc),a0
  9260.     move.l    d0,(a0)
  9261.     jsr    numdec
  9262.     move.l    d0,a0
  9263.     lea    .text2n(pc),a1
  9264. .loop
  9265.     move.b    (a0)+,(a1)+
  9266.     bne.b    .loop
  9267.  
  9268.     lea    .linepos(pc),a0
  9269.     move.l    linepos,(a0)
  9270.     lea    .text1(pc),a1
  9271.     lea    .text2(pc),a2
  9272.  
  9273.     bsr    requestinteger
  9274.     tst.l    d0
  9275.     bmi.b    .exit
  9276.     beq.b    .exit
  9277.     move.l    .linepos(pc),d1
  9278.     cmp.l    .max(pc),d1
  9279.     bhi.b    .again
  9280. .exit
  9281.     rts
  9282. .max        dc.l    0
  9283. .linepos    dc.l    0
  9284. .text1    dc.b    "Go to line",0
  9285. .text2    dc.b    "Min: 0 -- Max: "
  9286. .text2n    dc.b    "xxxxxxxx",0
  9287.     even
  9288. ;in:
  9289. * a0    default number
  9290. * a1    text1
  9291. * a2    text2
  9292. ;ut:
  9293. * d0    -1    avsluta Textread
  9294. * d0    0    allt ok, byt inte rad
  9295. * d0    1    allt ok, byt rad
  9296. requestinteger:
  9297.     lea    .init_number(pc),a3
  9298.     move.l    (a0),(a3)
  9299.     lea    .number(pc),a3
  9300.     move.l    a0,(a3)
  9301.     lea    .init_text1(pc),a3
  9302.     move.l    a1,(a3)
  9303.     lea    .init_text2(pc),a3
  9304.     move.l    a2,(a3)
  9305.  
  9306.     move.l    screenptr,a1
  9307.     bsr    OpenintegerreqWindow
  9308.     tst.l    d0
  9309.     bne.b    .error
  9310.     jsr    lockwindow
  9311.  
  9312.     BASE    gt
  9313.     move.l    integerreqGadgets+GD_iw_integer*4(pc),a0
  9314.     move.l    integerreq(pc),a1
  9315.     suba.l    a2,a2
  9316.     lea    .init_number_tags(pc),a3
  9317.     call    GT_SetGadgetAttrsA
  9318.  
  9319.     move.l    integerreqGadgets+GD_iw_text1*4(pc),a0
  9320.     move.l    integerreq(pc),a1
  9321.     suba.l    a2,a2
  9322.     lea    .init_text1_tags(pc),a3
  9323.     call    GT_SetGadgetAttrsA
  9324.  
  9325.     move.l    integerreqGadgets+GD_iw_text2*4(pc),a0
  9326.     move.l    integerreq(pc),a1
  9327.     suba.l    a2,a2
  9328.     lea    .init_text2_tags(pc),a3
  9329.     call    GT_SetGadgetAttrsA
  9330.  
  9331.     BASE    intui
  9332.     move.l    integerreqGadgets+GD_iw_integer*4(pc),a0
  9333.     move.l    integerreq(pc),a1
  9334.     suba.l    a2,a2
  9335.     call    ActivateGadget
  9336.  
  9337.     lea    .strukt(pc),a0
  9338.     move.l    integerreq(pc),(a0)
  9339.     bsr    handlerequestwindow
  9340.     move.l    d0,-(sp)
  9341.     jsr    unlockwindow
  9342.     bsr    CloseintegerreqWindow
  9343.     move.l    (sp)+,d0
  9344.     rts
  9345. .error
  9346.     moveq    #0,d0
  9347.     rts
  9348. .number
  9349.     dc.l    0
  9350. .strukt
  9351.     dc.l    0
  9352.     dc.l    .render
  9353.     dc.l    .strukt_v
  9354.     dc.l    .strukt_r
  9355.     dc.l    .strukt_g
  9356.  
  9357. .strukt_v
  9358.     HRWv    "u",.fn_use
  9359.     HRWv    $0d,.fn_use
  9360.     HRWv    "c",.fn_cancel
  9361.     HRWv    $1b,.fn_cancel
  9362.     HRWv    -1,-1
  9363. .strukt_r
  9364.     HRWr    -1,-1,-1
  9365. .strukt_g
  9366.     HRWg    GD_iw_use,.fn_usegad
  9367.     HRWg    GD_iw_cancel,.fn_cancelgad
  9368.     HRWg    GD_iw_integer,.fn_integer
  9369.     HRWg    -1,-1
  9370.  
  9371. .render
  9372. ;    bsr    integerreqRender
  9373.     rts
  9374.  
  9375. .fn_use
  9376.     move.l    hrw_window(a5),a2
  9377.     move.l    integerreqGadgets+GD_iw_use*4(pc),a3
  9378.     jsr    PressButton
  9379. .fn_usegad
  9380.     move.l    .number(pc),a1
  9381.     move.l    integerreqGadgets+GD_iw_integer*4(pc),a0
  9382.     move.l    gg_SpecialInfo(a0),a0
  9383.     move.l    si_LongInt(a0),(a1)
  9384.     moveq    #1+1,d0
  9385.     rts
  9386. .fn_cancel
  9387.     move.l    hrw_window(a5),a2
  9388.     move.l    integerreqGadgets+GD_iw_cancel*4(pc),a3
  9389.     jsr    PressButton
  9390. .fn_cancelgad
  9391.     moveq    #0+1,d0
  9392.     rts
  9393. .fn_integer
  9394.     and.w    #IEQUALIFIERB_LSHIFT!IEQUALIFIERB_RSHIFT,d4
  9395.     beq.w    .fn_use
  9396.     moveq    #0,d0
  9397.     rts
  9398.  
  9399. .init_number_tags
  9400.     dc.l    GTIN_Number
  9401. .init_number
  9402.     dc.l    0
  9403.     dc.l    TAG_DONE
  9404.  
  9405. .init_text1_tags
  9406.     dc.l    GTTX_Text
  9407. .init_text1
  9408.     dc.l    0
  9409.     dc.l    TAG_DONE
  9410.  
  9411. .init_text2_tags
  9412.     dc.l    GTTX_Text
  9413. .init_text2
  9414.     dc.l    0
  9415.     dc.l    TAG_DONE
  9416.  
  9417. ;in:
  9418. * a0    struktur
  9419. handlerequestwindow
  9420.     move.l    a0,a5
  9421. .handlerequesterwindow_loop
  9422.  
  9423.     clr.w    .status
  9424.     base    exec
  9425.     move.l    hrw_window(a5),a0
  9426.     move.l    wd_UserPort(a0),a0
  9427.     move.b    MP_SIGBIT(a0),d1
  9428.     moveq    #0,d0
  9429.     bset    d1,d0
  9430.     lea    .usersignal(pc),a0
  9431.     move.l    d0,(a0)
  9432.  
  9433.     bset    #SIGBREAKB_CTRL_C,d0
  9434.  
  9435.     call    Wait
  9436.     lea    .signal(pc),a0
  9437.     move.l    d0,(a0)
  9438.     move.l    d0,d1
  9439.     and.l    .usersignal(pc),d1    ;signalerade userport?
  9440.     beq.W    .nouserport
  9441.                     ;joo..
  9442. .handleIDCMP
  9443.     BASE    gt
  9444.     move.l    hrw_window(a5),a0
  9445.     move.l    wd_UserPort(a0),a0    ;userport
  9446.     call    GT_GetIMsg
  9447.     tst.l    d0
  9448.     beq.w    .nomoremsgs
  9449.     move.l    d0,a0
  9450.  
  9451.     move.l    im_Class(a0),d2
  9452.  
  9453.     move.l    im_IAddress(a0),a2
  9454.     moveq    #0,d3
  9455.     move.w    im_Code(a0),d3
  9456.     move.w    im_Qualifier(a0),d4
  9457.     move.l    im_Seconds(a0),d5
  9458.     move.l    im_Micros(a0),d6
  9459.  
  9460.     move.l    a0,a1
  9461.     call    GT_ReplyIMsg
  9462.  
  9463.     cmp.l    #IDCMP_VANILLAKEY,d2
  9464.     bne.w    .dontcheckVkeys
  9465.     move.l    hrw_vkeys(a5),a0
  9466. .Vkeys_loop
  9467.     move.w    (a0),d0
  9468.     cmp.w    #-1,d0
  9469.     beq.b    .handleIDCMP
  9470.     cmp.w    d3,d0
  9471.     bne.b    .Vkeys_nope
  9472.     move.l    2(a0),a0
  9473.     jsr    (a0)
  9474.     bra.w    .fn_return
  9475. .Vkeys_nope
  9476.     add.w    #HWRv_SIZEOF,a0
  9477.     bra.b    .Vkeys_loop
  9478.  
  9479. .dontcheckVkeys
  9480.     cmp.l    #IDCMP_RAWKEY,d2
  9481.     bne.w    .dontcheckRkeys
  9482.  
  9483.     move.l    hrw_rkeys(a5),a0
  9484. .Rkeys_loop
  9485.     move.w    (a0),d0
  9486.     beq.b    .Rkeys_testcode
  9487.     cmp.w    #-1,d0
  9488.     beq.b    .handleIDCMP
  9489.     and.w    d4,d0
  9490.     beq.b    .Rkeys_nope
  9491. .Rkeys_testcode
  9492.     cmp.w    2(a0),d3
  9493.     bne.b    .Rkeys_nope
  9494.     move.l    4(a0),a0
  9495.     jsr    (a0)
  9496.     bra.b    .fn_return
  9497. .Rkeys_nope
  9498.     add.w    #HWRr_SIZEOF,a0
  9499.     bra.b    .Rkeys_loop
  9500.  
  9501. .dontcheckRkeys
  9502.     cmp.l    #IDCMP_GADGETUP,d2
  9503.     bne.w    .dontpressgadgets
  9504.     move.w    gg_GadgetID(a2),d1
  9505.  
  9506.     move.l    hrw_gadgets(a5),a0
  9507. .gad_loop
  9508.     move.w    (a0),d0
  9509.     cmp.w    #-1,d0
  9510.     beq.w    .handleIDCMP
  9511.     cmp.w    d1,d0
  9512.     bne.b    .gad_nope
  9513.     move.l    2(a0),a0
  9514.     jsr    (a0)
  9515.     bra.b    .fn_return
  9516. .gad_nope
  9517.     add.w    #HWRg_SIZEOF,a0
  9518.     bra.b    .gad_loop
  9519.  
  9520. .dontpressgadgets
  9521.     cmp.l    #IDCMP_REFRESHWINDOW,d2
  9522.     bne.s    .dontrefreshwindow
  9523.     BASE    gt
  9524.     move.l    hrw_window(a5),a0
  9525.     call    GT_BeginRefresh
  9526.  
  9527.     move.l    hrw_render(a5),a0
  9528.     jsr    (a0)
  9529.  
  9530.     BASE    gt
  9531.     move.l    hrw_window(a5),a0
  9532.     moveq    #TRUE,d0
  9533.     call    GT_EndRefresh
  9534. .dontrefreshwindow
  9535.     bra.w    .handleIDCMP
  9536. .fn_return
  9537.     move.w    d0,.status
  9538. .nomoremsgs
  9539.     tst.w    .status
  9540.     bne.s    .exit
  9541.  
  9542. .nouserport
  9543.     move.l    .signal(pc),d1
  9544.     and.l    #SIGBREAKF_CTRL_C,d1
  9545.     beq.B    .nobreak
  9546.     lea    status,a0
  9547.     bset    #s_exit,(a0)        ;om ctrl_c från cli, sluta direkt!
  9548.     moveq    #err_exitnow,d0
  9549.     rts
  9550. .nobreak
  9551.     bra.w    .handlerequesterwindow_loop
  9552. .exit
  9553.     moveq    #0,d0
  9554.     move.w    .status(pc),d0
  9555.     subq.l    #1,d0
  9556.     rts
  9557. .signal        dc.l    0
  9558. .usersignal    dc.l    0
  9559. .status        dc.w    0
  9560.  
  9561.  
  9562.  
  9563.  
  9564.  
  9565. printfile:
  9566.     tst.l    filelen
  9567.     beq.w    .exit
  9568.  
  9569.     BASE    intui
  9570.     move.l    windowptr,a0
  9571.     move.l    #-1,a1
  9572.     lea    .printing(pc),a2
  9573.     call    SetWindowTitles
  9574.  
  9575.     BASE    exec
  9576.     call    CreateMsgPort
  9577.     lea    .port(pc),a0
  9578.     move.l    d0,(a0)
  9579.     beq.w    .error
  9580.     move.l    d0,a0
  9581. ;    ifgt    IOSTD_SIZE,iopcr_SIZEOF
  9582.     moveq    #IOSTD_SIZE,d0
  9583. ;    else
  9584. ;    moveq    #iopcr_SIZEOF,d0
  9585. ;    endif
  9586.     call    CreateIORequest        ;union IOStdReq och IOPrtCmdReq
  9587.     lea    mpio(pc),a0
  9588.     move.l    d0,(a0)
  9589.     beq.w    .error
  9590.     move.l    d0,a1
  9591.     move.l    unit,d0            ;skrivarenhet
  9592.     lea    .printer(pc),a0
  9593.     moveq    #0,d1
  9594.     call    OpenDevice
  9595.     lea    .deverr(pc),a0
  9596.     move.l    d0,(a0)
  9597.     bne.w    .error
  9598.  
  9599. ;    call    Forbid            ;ingen multitasking nu
  9600.     lea    tabsize,a0
  9601.     move.l    (a0),-(sp)
  9602.     move.l    mptab,(a0)
  9603.     lea    printtabbar,a0
  9604.     jsr    fixatabbar
  9605.     lea    tabsize,a0
  9606.     move.l    (sp)+,(a0)
  9607. ;    base    exec
  9608. ;    call    Permit
  9609.  
  9610.     move.l    mpio(pc),a0
  9611.     move.l    IO_DEVICE(a0),a0
  9612.     lea    pd_Preferences(a0),a0
  9613.     move.w    pf_PrintLeftMargin(a0),d0
  9614. ;    subq.w    #1,d0
  9615.     move.w    pf_PrintRightMargin(a0),d1
  9616.     sub.w    d0,d1
  9617.     lea    .prwidth(pc),a1
  9618.     move.w    d1,(a1)
  9619.     beq.w    .error            ;inga tecken/rad alls?!
  9620.     move.w    pf_PaperLength(a0),d0
  9621.     lea    .prheight(pc),a1
  9622.     move.w    d0,(a1)
  9623.     lea    mppage,a0
  9624.     clr.w    (a0)
  9625.  
  9626.     base    exec
  9627.     move.l    mpio(pc),a1
  9628.     lea    temp,a0
  9629.     move.l    a0,IO_DATA(a1)
  9630.     move.w    #PRD_QUERY,IO_COMMAND(a1)
  9631.     call    DoIO
  9632.     tst.l    d0
  9633.     bne.w    .error
  9634.     move.l    mpio(pc),a1
  9635.     cmp.l    #1,IO_ACTUAL(a1)
  9636.     bne.b    .notpar
  9637.     move.b    temp,d0
  9638.     btst    #0,d0
  9639.     bne.w    .offline    ;offline
  9640.     btst    #1,d0
  9641.     bne.w    .nopaper    ;paper out
  9642. .notpar
  9643.     lea    .prheight(pc),a1
  9644.     move.b    mpinfo,d0
  9645.     beq.b    .ingetuppe
  9646.     subq.w    #2,(a1)
  9647. .ingetuppe
  9648.     move.w    #aRIN,d0
  9649.     bsr.w    mprintcommand
  9650.     bne.w    .error
  9651.     move.l    fileaddr,a2
  9652.     move.l    filelen,a3
  9653.     add.l    a2,a3
  9654. .nextpage
  9655.     lea    mppage,a0
  9656.     addq.w    #1,(a0)
  9657.  
  9658.     move.l    a2,a4
  9659.     move.l    a3,a5
  9660.     move.b    mpinfo,d0
  9661.     beq.b    .tileprinted
  9662.     lea    mpheader,a2
  9663.     move.b    (a2)+,d0
  9664.     bsr.w    mprintstyle
  9665.     tst.l    d0
  9666.     bne.w    .error
  9667.  
  9668.     bsr.w    mpgettitfoot
  9669.     BASE    exec
  9670.     move.l    mpio(pc),a1
  9671.     move.l    #-1,IO_LENGTH(a1)
  9672.     move.l    a0,IO_DATA(a1)
  9673.     move.w    #CMD_WRITE,IO_COMMAND(a1)
  9674.     call    DoIO
  9675.     tst.l    d0
  9676.     bne.w    .error
  9677.     move.w    #aNEL,d0
  9678.     bsr.w    mprintcommand
  9679.     bne.w    .error
  9680.     move.w    #aNEL,d0
  9681.     bsr.w    mprintcommand
  9682.     bne.w    .error
  9683. .tileprinted
  9684.     move.w    #aSGR0,d0
  9685.     bsr.w    mprintcommand
  9686.     bne.w    .error
  9687.     move.l    a4,a2
  9688.     move.l    a5,a3
  9689.     move.w    .prheight(pc),d7
  9690. .nextline
  9691.     suba.l    a1,a1            ;tala om att början på rad!
  9692.  
  9693.     lea    temp,a0
  9694.     move.w    .prwidth(pc),d1
  9695.     moveq    #0,d2
  9696. .nextchar
  9697.     moveq    #0,d0
  9698.     move.b    (a2)+,d0
  9699.     move.b    d0,(a0)+
  9700.     cmp.l    a2,a3
  9701.     beq.w    .textslut
  9702.     cmp.b    #LF,d0
  9703.     beq.b    .printline
  9704.     cmp.b    #12,d0
  9705.     bne.b    .not12
  9706.     moveq    #0,d7            ;sid-slut
  9707.     bra.b    .printline
  9708. .not12
  9709.     cmp.b    #" ",d0
  9710.     bne.b    .notSPACE
  9711.     move.l    a0,a1
  9712.     move.l    a2,a5
  9713. .notSPACE
  9714.     cmp.b    #TAB,d0
  9715.     bne.b    .notTAB
  9716.     move.l    a0,a1
  9717.     move.l    a2,a5
  9718.     lea    printtabbar,a4
  9719.     moveq    #0,d0
  9720.     move.b    (a4,d2.w),d0
  9721.     sub.w    d2,d0
  9722.     move.b    (a4,d2.w),d2
  9723.     subq.w    #1,d0
  9724.     subq.l    #1,a0            ;bort med tab!
  9725. .fillspace
  9726.     move.b    #" ",(a0)+
  9727.     dbf    d0,.fillspace
  9728.     bra.b    .charfinished
  9729. .notTAB
  9730.     cmp.b    #" ",d0
  9731.     blo.b    .nonascii
  9732.     cmp.b    #$80,d0
  9733.     blo.b    .ascii
  9734.     cmp.b    #$a0,d0
  9735.     bhs.b    .ascii
  9736. .nonascii
  9737.     move.b    #".",-1(a0)
  9738. .ascii
  9739.     addq.w    #1,d2
  9740. .charfinished
  9741.     cmp.w    d1,d2
  9742.     blo.B    .nextchar
  9743.     sub.w    d1,d2            ;om man har gått över gränsen(=tab)
  9744.     sub.w    d2,a0            ;klipp av !
  9745.     move.b    mpww,d0
  9746.     beq.b    .noww
  9747.     move.l    a1,d0
  9748.     beq.b    .noww
  9749.     move.l    a1,a0
  9750.     subq.l    #1,a0            ;ta bort spacet oxå!
  9751.     move.l    a5,a2
  9752. .noww
  9753.     move.b    #10,(a0)+
  9754. .printline
  9755.     clr.b    (a0)
  9756.     move.l    mpio(pc),a1
  9757.     move.l    #-1,IO_LENGTH(a1)
  9758.     lea    temp,a0
  9759.     move.l    a0,IO_DATA(a1)
  9760.     move.w    #CMD_WRITE,IO_COMMAND(a1)
  9761.     call    DoIO
  9762.     tst.l    d0
  9763.     bne.B    .error
  9764.     dbf    d7,.nextline        ;<-
  9765.     bra.w    .nextpage
  9766. .textslut
  9767.     clr.b    (a0)
  9768.     move.l    mpio(pc),a1
  9769.     move.l    #-1,IO_LENGTH(a1)
  9770.     lea    temp,a0
  9771.     move.l    a0,IO_DATA(a1)
  9772.     move.w    #CMD_WRITE,IO_COMMAND(a1)
  9773.     call    DoIO
  9774.     move.l    mpio(pc),a1
  9775.     move.l    #-1,IO_LENGTH(a1)
  9776.     lea    .cls,a0
  9777.     move.l    a0,IO_DATA(a1)
  9778.     move.w    #CMD_WRITE,IO_COMMAND(a1)
  9779.     call    DoIO
  9780.     move.l    mpio(pc),a1
  9781.     move.w    #CMD_FLUSH,IO_COMMAND(a1)
  9782.     call    DoIO
  9783.     move.l    mpio(pc),a1
  9784.     call    AbortIO
  9785.     move.l    mpio(pc),a1
  9786.     call    WaitIO
  9787. .error
  9788.     BASE    exec
  9789.     move.l    mpio(pc),d0
  9790.     beq.B    .noio
  9791.     move.l    .deverr(pc),d0
  9792.     bne.b    .wasdeverr
  9793.     move.l    mpio(pc),a1
  9794.     call    CloseDevice
  9795.     lea    .deverr(pc),a0
  9796.     clr.l    (a0)
  9797. .wasdeverr
  9798.     move.l    mpio(pc),a0
  9799.     call    DeleteIORequest
  9800.     lea    mpio(pc),a0
  9801.     clr.l    (a0)
  9802. .noio
  9803.     move.l    .port(pc),d0
  9804.     beq.B    .noport
  9805.     move.l    d0,a0
  9806.     call    DeleteMsgPort
  9807.     lea    .port(pc),a0
  9808.     clr.l    (a0)
  9809. .noport
  9810.     BASE    intui
  9811.     move.l    windowptr,a0
  9812.     move.l    #-1,a1
  9813.     lea    screentitle,a2
  9814.     call    SetWindowTitles
  9815. .exit
  9816.     moveq    #0,d0
  9817.     rts
  9818. .offline
  9819.     bsr.b    .error
  9820.     lea    .offlinemessage(pc),a1
  9821.     lea    oktext,a2
  9822.     suba.l    a4,a4
  9823.     jsr    requester
  9824.     moveq    #0,d0
  9825.     rts
  9826. .nopaper
  9827.     bsr.b    .error
  9828.     lea    .nopapermessage(pc),a1
  9829.     lea    oktext,a2
  9830.     suba.l    a4,a4
  9831.     jsr    requester
  9832.     moveq    #0,d0
  9833.     rts
  9834. .offlinemessage
  9835.     dc.b    "Printer is not on-line.",0
  9836. .nopapermessage
  9837.     dc.b    "Printer is out of paper.",0
  9838.     even
  9839.  
  9840. .prwidth    dc.w    0
  9841. .prheight    dc.w    0
  9842. .port        dc.l    0
  9843. .deverr        dc.l    0
  9844. .printer    dc.b    "printer.device",0
  9845. .printing    dc.b    "Printing file...",0
  9846. .cls        dc.b    12,0
  9847.     even
  9848. mpio:        dc.l    0
  9849.  
  9850. mprintstyle:
  9851.     move.w    d0,d2
  9852.     move.w    #aSGR0,d0
  9853.     bsr.B    mprintcommand
  9854.     bne.B    .error
  9855.     btst    #0,d2
  9856.     beq.B    .nobold
  9857.     move.w    #aSGR1,d0        ;fet
  9858.     bsr.B    mprintcommand
  9859.     bne.B    .error
  9860. .nobold
  9861.     btst    #1,d2
  9862.     beq.B    .noital
  9863.     move.w    #aSGR3,d0        ;kursiv
  9864.     bsr.B    mprintcommand
  9865.     bne.B    .error
  9866. .noital
  9867.     btst    #2,d2
  9868.     beq.B    .nounder
  9869.     move.w    #aSGR4,d0        ;understryk
  9870.     bsr.B    mprintcommand
  9871.     bne.B    .error
  9872. .nounder
  9873.     moveq    #0,d0
  9874. .error
  9875.     rts
  9876. ;in:
  9877. * d0    kommando
  9878. ;ut:
  9879. * Z-flaggan 0 om fel (d0<>0)
  9880. mprintcommand:
  9881.     BASE    exec
  9882.     move.l    mpio(pc),a1
  9883.     move.w    d0,io_PrtCommand(a1)
  9884.     clr.l    io_Parm0(a1)        ;0-3
  9885.     move.w    #PRD_PRTCOMMAND,IO_COMMAND(a1)
  9886.     call    DoIO
  9887.     tst.l    d0
  9888.     rts
  9889. ;in:
  9890. * a2    pek till tre bytar
  9891. ;ut:
  9892. * a0    sträng att skriva ut,0
  9893. mpgettitfoot:
  9894.     lea    temp+256,a0
  9895.     moveq    #79,d0
  9896. .fill
  9897.     move.b    #" ",(a0)+
  9898.     dbf    d0,.fill
  9899.     clr.b    (a0)
  9900.  
  9901.     move.b    (a2)+,d0
  9902.     bsr.B    .retright
  9903.     tst.l    d0
  9904.     beq.b    .next1
  9905.     lea    temp+256,a1
  9906. .copy1
  9907.     move.b    (a0)+,(a1)+
  9908.     bne.b    .copy1
  9909.     move.b    #" ",-(a1)
  9910. .next1
  9911.     move.b    (a2)+,d0
  9912.     bsr.B    .retright
  9913.     tst.l    d0
  9914.     beq.b    .next2
  9915.     lsr.l    #1,d0
  9916.     lea    temp+256+40,a1
  9917.     sub.l    d0,a1
  9918. .copy2
  9919.     move.b    (a0)+,(a1)+
  9920.     bne.b    .copy2
  9921.     move.b    #" ",-(a1)
  9922. .next2
  9923.     move.b    (a2)+,d0
  9924.     bsr.B    .retright
  9925.     lea    temp+256+80,a1
  9926.     tst.l    d0
  9927.     beq.b    .next3
  9928.     sub.l    d0,a1
  9929. .copy3
  9930.     move.b    (a0)+,(a1)+
  9931.     bne.b    .copy3
  9932. .next3
  9933.     lea    temp+256,a0
  9934.     rts
  9935. .retright
  9936.     cmp.b    #1,d0
  9937.     bne.B    .notfilename
  9938.     lea    filename,a0
  9939.     moveq    #30,d0            ;längd
  9940.     rts
  9941. .notfilename
  9942.     cmp.b    #2,d0
  9943.     bne.B    .nottitle
  9944.     lea    mptitle,a0
  9945.     moveq    #30,d0            ;längd
  9946.     rts
  9947. .nottitle
  9948.     cmp.b    #3,d0
  9949.     bne.B    .notdate
  9950.     lea    .datetime(pc),a0
  9951.     move.b    #FORMAT_INT,dat_Format(a0)
  9952.     lea    temp,a1
  9953.     move.l    a1,dat_StrDate(a0)
  9954.     BASE    dos
  9955.     move.l    a0,d1
  9956.     call    DateStamp
  9957.     move.l    d0,d1
  9958.     call    DateToStr
  9959.     tst.l    d0
  9960.     beq.b    .rrexit
  9961.     moveq    #-1,d0
  9962.     lea    temp,a0
  9963. .findnull
  9964.     addq.l    #1,d0
  9965.     tst.b    (a0)+
  9966.     bne.b    .findnull
  9967.     lea    temp,a0
  9968.     rts
  9969. .notdate
  9970.     cmp.b    #4,d0
  9971.     bne.B    .notsidnum
  9972.     moveq    #0,d0
  9973.     move.w    mppage,d0
  9974.     jsr    numdec
  9975.     lea    temp,a1
  9976.     move.l    d0,a0
  9977.     moveq    #3,d0
  9978.     move.b    #"-",(a1)+
  9979.     move.b    #" ",(a1)+
  9980. .copyside
  9981.     addq.w    #1,d0
  9982.     move.b    (a0)+,(a1)+
  9983.     bne.b    .copyside
  9984.     move.b    #" ",-1(a1)
  9985.     move.b    #"-",(a1)+
  9986.     clr.b    (a1)
  9987.     lea    temp,a0
  9988.     rts
  9989. .notsidnum
  9990. .rrexit
  9991.     moveq    #0,d0
  9992.     rts    
  9993. .datetime
  9994.     blk.b    dat_SIZEOF
  9995. printoptions:
  9996.     lea    pol,a0
  9997.     lea    .l2(pc),a1
  9998.     move.l    (a0)+,(a1)+
  9999.     move.l    (a0)+,(a1)+
  10000.     move.l    (a0)+,(a1)+
  10001.     move.l    (a0)+,(a1)+
  10002.     move.l    (a0)+,(a1)+
  10003.     move.l    (a0)+,(a1)+
  10004.     move.l    (a0)+,(a1)+
  10005.  
  10006.     lea    .leftactive(pc),a0
  10007.     move.l    pol,(a0)
  10008.     lea    .midactive(pc),a0
  10009.     move.l    pom,(a0)
  10010.     lea    .rightactive(pc),a0
  10011.     move.l    por,(a0)
  10012.     lea    .wwon(pc),a0
  10013.     move.l    pow,(a0)
  10014.     lea    .tabsize(pc),a0
  10015.     move.l    mptab,(a0)
  10016.     lea    .boldon(pc),a0
  10017.     move.l    pob,(a0)
  10018.     lea    .italon(pc),a0
  10019.     move.l    poi,(a0)
  10020.     lea    .underon(pc),a0
  10021.     move.l    pou,(a0)
  10022.  
  10023.     move.l    cwidthp,d0
  10024.     sub.l    #428,d0
  10025.     lsr.l    #1,d0
  10026.     lea    .pwinx(pc),a0
  10027.     move.l    d0,(a0)
  10028.     move.l    pheight,d0
  10029.     sub.l    #142,d0
  10030.     lsr.l    #1,d0
  10031.     lea    .pwiny(pc),a0
  10032.     move.l    d0,(a0)
  10033.  
  10034.     BASE    intui
  10035.     lea    .pwindowonscreen(pc),a0
  10036.     move.l    screenptr,(a0)
  10037.     suba.l    a0,a0
  10038.     lea    .pwindowtags(pc),a1
  10039.     call    OpenWindowTagList
  10040.     lea    .pwindowptr(pc),a0
  10041.     move.l    d0,(a0)
  10042.     beq.w    .error
  10043.  
  10044.     BASE    gt
  10045.     lea    .pgadgetptr(pc),a0
  10046.     call    CreateContext
  10047.     move.l    d0,d7
  10048.  
  10049.     lea    .pnewgadget(pc),a3
  10050.     move.w    #20,gng_LeftEdge(a3)
  10051.     move.w    #30,gng_TopEdge(a3)
  10052.     clr.w    gng_Width(a3)
  10053.     clr.w    gng_Height(a3)
  10054.     clr.l    gng_GadgetText(a3)
  10055.     lea    topaz8font,a0
  10056.     move.l    a0,gng_TextAttr(a3)
  10057.     move.l    #PLACETEXT_RIGHT,gng_Flags(a3)
  10058.     move.l    screenvi,gng_VisualInfo(a3)
  10059.     clr.w    gng_GadgetID(a3)        ;start noll
  10060.     clr.l    gng_UserData(a3)
  10061.  
  10062.     move.l    d7,a0
  10063.     move.l    a3,a1
  10064.     lea    .lefttags(pc),a2
  10065.     move.l    #MX_KIND,d0
  10066.     call    CreateGadgetA
  10067.     lea    .leftgadget(pc),a0
  10068.     move.l    d0,(a0)
  10069.     beq.w    .error
  10070.     move.l    d0,d7
  10071.  
  10072.     addq.w    #1,gng_GadgetID(a3)
  10073.     add.w    #150,gng_LeftEdge(a3)
  10074.  
  10075.     move.l    d7,a0
  10076.     move.l    a3,a1
  10077.     lea    .midtags(pc),a2
  10078.     move.l    #MX_KIND,d0
  10079.     call    CreateGadgetA
  10080.     lea    .midgadget(pc),a0
  10081.     move.l    d0,(a0)
  10082.     beq.w    .error
  10083.     move.l    d0,d7
  10084.  
  10085.     addq.w    #1,gng_GadgetID(a3)
  10086.     add.w    #150,gng_LeftEdge(a3)
  10087.  
  10088.     move.l    d7,a0
  10089.     move.l    a3,a1
  10090.     lea    .righttags(pc),a2
  10091.     move.l    #MX_KIND,d0
  10092.     call    CreateGadgetA
  10093.     lea    .rightgadget(pc),a0
  10094.     move.l    d0,(a0)
  10095.     beq.w    .error
  10096.     move.l    d0,d7
  10097.  
  10098.     addq.w    #1,gng_GadgetID(a3)
  10099.     move.w    #105,gng_TopEdge(a3)
  10100.     move.w    #170,gng_LeftEdge(a3)
  10101.     lea    .ww(pc),a0
  10102.     move.l    a0,gng_GadgetText(a3)
  10103.  
  10104.     move.l    d7,a0
  10105.     move.l    a3,a1
  10106.     lea    .wwtags(pc),a2
  10107.     move.l    #CHECKBOX_KIND,d0
  10108.     call    CreateGadgetA
  10109.     lea    .wwgadget(pc),a0
  10110.     move.l    d0,(a0)
  10111.     beq.w    .error
  10112.     move.l    d0,d7
  10113.  
  10114.     addq.w    #1,gng_GadgetID(a3)
  10115.     move.w    #125,gng_TopEdge(a3)
  10116.     move.w    #20,gng_LeftEdge(a3)
  10117.     move.w    #12,gng_Height(a3)
  10118.     move.w    #60,gng_Width(a3)
  10119.     move.l    #PLACETEXT_IN,gng_Flags(a3)
  10120.     lea    .print(pc),a0
  10121.     move.l    a0,gng_GadgetText(a3)
  10122.     
  10123.     move.l    d7,a0
  10124.     move.l    a3,a1
  10125.     lea    tag_done,a2
  10126.     move.l    #BUTTON_KIND,d0
  10127.     call    CreateGadgetA
  10128.     lea    .printgadget(pc),a0
  10129.     move.l    d0,(a0)
  10130.     beq.w    .error
  10131.     move.l    d0,d7
  10132.  
  10133.     addq.w    #1,gng_GadgetID(a3)
  10134.     move.w    #185,gng_LeftEdge(a3)
  10135.     lea    .use(pc),a0
  10136.     move.l    a0,gng_GadgetText(a3)
  10137.     
  10138.     move.l    d7,a0
  10139.     move.l    a3,a1
  10140.     lea    tag_done,a2
  10141.     move.l    #BUTTON_KIND,d0
  10142.     call    CreateGadgetA
  10143.     lea    .usegadget(pc),a0
  10144.     move.l    d0,(a0)
  10145.     beq.w    .error
  10146.     move.l    d0,d7
  10147.  
  10148.     addq.w    #1,gng_GadgetID(a3)
  10149.     move.w    #348,gng_LeftEdge(a3)
  10150.     lea    .cancel(pc),a0
  10151.     move.l    a0,gng_GadgetText(a3)
  10152.     
  10153.     move.l    d7,a0
  10154.     move.l    a3,a1
  10155.     lea    tag_done,a2
  10156.     move.l    #BUTTON_KIND,d0
  10157.     call    CreateGadgetA
  10158.     lea    .cancelgadget(pc),a0
  10159.     move.l    d0,(a0)
  10160.     beq.w    .error
  10161.     move.l    d0,d7
  10162.  
  10163.     addq.w    #1,gng_GadgetID(a3)
  10164.     move.w    #90,gng_TopEdge(a3)
  10165.     move.w    #68,gng_LeftEdge(a3)
  10166.     move.w    #261,gng_Width(a3)
  10167.     move.l    #PLACETEXT_LEFT,gng_Flags(a3)
  10168.     lea    .title(pc),a0
  10169.     move.l    a0,gng_GadgetText(a3)
  10170.  
  10171.     move.l    d7,a0
  10172.     move.l    a3,a1
  10173.     lea    .titletags(pc),a2
  10174.     move.l    #STRING_KIND,d0
  10175.     call    CreateGadgetA
  10176.     lea    .titlegadget(pc),a0
  10177.     move.l    d0,(a0)
  10178.     beq.w    .error
  10179.     move.l    d0,d7
  10180.  
  10181.     addq.w    #1,gng_GadgetID(a3)
  10182.     move.w    #105,gng_TopEdge(a3)
  10183.     move.w    #92,gng_LeftEdge(a3)
  10184.     move.w    #37,gng_Width(a3)
  10185.     lea    .tab(pc),a0
  10186.     move.l    a0,gng_GadgetText(a3)
  10187.  
  10188.     move.l    d7,a0
  10189.     move.l    a3,a1
  10190.     lea    .tabtags(pc),a2
  10191.     move.l    #INTEGER_KIND,d0
  10192.     call    CreateGadgetA
  10193.     lea    .tabgadget(pc),a0
  10194.     move.l    d0,(a0)
  10195.     beq.w    .error
  10196.     move.l    d0,d7
  10197.  
  10198.     move.w    #75,gng_TopEdge(a3)
  10199.     addq.w    #1,gng_GadgetID(a3)
  10200.     move.w    #20,gng_LeftEdge(a3)
  10201.     move.l    #PLACETEXT_RIGHT,gng_Flags(a3)
  10202.     lea    .bold(pc),a0
  10203.     move.l    a0,gng_GadgetText(a3)
  10204.  
  10205.     move.l    d7,a0
  10206.     move.l    a3,a1
  10207.     lea    .boldtags(pc),a2
  10208.     move.l    #CHECKBOX_KIND,d0
  10209.     call    CreateGadgetA
  10210.     lea    .boldgadget(pc),a0
  10211.     move.l    d0,(a0)
  10212.     beq.w    .error
  10213.     move.l    d0,d7
  10214.  
  10215.     addq.w    #1,gng_GadgetID(a3)
  10216.     add.w    #150,gng_LeftEdge(a3)
  10217.     lea    .under(pc),a0
  10218.     move.l    a0,gng_GadgetText(a3)
  10219.  
  10220.     move.l    d7,a0
  10221.     move.l    a3,a1
  10222.     lea    .undertags(pc),a2
  10223.     move.l    #CHECKBOX_KIND,d0
  10224.     call    CreateGadgetA
  10225.     lea    .undergadget(pc),a0
  10226.     move.l    d0,(a0)
  10227.     beq.w    .error
  10228.     move.l    d0,d7
  10229.  
  10230.     addq.w    #1,gng_GadgetID(a3)
  10231.     add.w    #150,gng_LeftEdge(a3)
  10232.     lea    .ital(pc),a0
  10233.     move.l    a0,gng_GadgetText(a3)
  10234.  
  10235.     move.l    d7,a0
  10236.     move.l    a3,a1
  10237.     lea    .italtags(pc),a2
  10238.     move.l    #CHECKBOX_KIND,d0
  10239.     call    CreateGadgetA
  10240.     lea    .italgadget(pc),a0
  10241.     move.l    d0,(a0)
  10242.     beq.w    .error
  10243.     move.l    d0,d7
  10244.  
  10245.     lea.l    filelen,a0
  10246.     tst.l    (a0)
  10247.     bne.b    .textinmem
  10248.     move.l    .printgadget(pc),a0
  10249.     or.w    #GFLG_DISABLED,gg_Flags(a0)
  10250. .textinmem
  10251.  
  10252.     move.l    .titlegadget(pc),a0
  10253.     move.l    .pwindowptr(pc),a1
  10254.     suba.l    a2,a2
  10255.     BASE    intui
  10256.     cmp.l    #2,pol
  10257.     beq.s    .aa
  10258.     call    OffGadget
  10259.     bra.S    .ba
  10260. .aa
  10261.     call    OnGadget
  10262. .ba
  10263.  
  10264.     BASE    intui
  10265.     move.l    .pwindowptr(pc),a0
  10266.     move.l    wd_RPort(a0),a0
  10267.     moveq    #0,d0
  10268.     moveq    #0,d1
  10269.     lea    .windowtext(pc),a1
  10270.     call    PrintIText
  10271.  
  10272.     move.l    .pwindowptr(pc),a0
  10273.     move.l    .pgadgetptr(pc),a1
  10274.     suba.l    a2,a2
  10275.     moveq    #0,d0
  10276.     moveq    #-1,d1
  10277.     call    AddGList
  10278.  
  10279.     move.l    .pwindowptr(pc),a1
  10280.     move.l    .pgadgetptr(pc),a0
  10281.     suba.l    a2,a2
  10282.     moveq    #-1,d0
  10283.     call    RefreshGList
  10284.     BASE    gt
  10285.     move.l    .pwindowptr(pc),a0
  10286.     suba.l    a1,a1
  10287.     call    GT_RefreshWindow
  10288. .wait
  10289.     BASE    exec
  10290.     move.l    .pwindowptr(pc),a0
  10291.     move.l    wd_UserPort(a0),a0
  10292.     call    WaitPort
  10293. .nextmsg
  10294.     BASE    gt
  10295.     move.l    .pwindowptr(pc),a0
  10296.     move.l    wd_UserPort(a0),a0
  10297.     call    GT_GetIMsg
  10298.     tst.l    d0
  10299.     beq.b    .wait
  10300.  
  10301.     moveq    #0,d3
  10302.     moveq    #0,d4
  10303.     move.l    d0,a0
  10304.     move.l    im_IAddress(a0),a2
  10305.     move.l    im_Class(a0),d2
  10306.     move.w    im_Code(a0),d3
  10307.     move.w    im_Qualifier(a0),d4
  10308.     move.l    d0,a1
  10309.     call    GT_ReplyIMsg
  10310.     cmp.l    #IDCMP_GADGETUP,d2
  10311.     bne.w    .notup
  10312.     cmp.w    #3,gg_GadgetID(a2)
  10313.     bne.b    .not3
  10314.     lea    pow+3,a0
  10315.     bchg    #0,(a0)            ;TRUE/FALSE
  10316. .not3
  10317.     cmp.w    #4,gg_GadgetID(a2)
  10318.     bne.b    .not4
  10319.     bsr.w    .error            ;stäng fönster
  10320.     bsr.w    .fixset
  10321.     moveq    #1,d0
  10322.     rts
  10323. .not4
  10324.     cmp.w    #5,gg_GadgetID(a2)
  10325.     bne.b    .not5
  10326.     bsr.w    .error            ;stäng fönster
  10327.     bra.w    .fixset
  10328. .not5
  10329.     cmp.w    #6,gg_GadgetID(a2)
  10330.     bne.b    .not6
  10331.     bsr.w    .error            ;stäng fönster
  10332.     bra.w    .resset
  10333. .not6
  10334.     cmp.w    #9,gg_GadgetID(a2)
  10335.     bne.b    .not9
  10336.     lea    pob+3,a0
  10337.     bchg    #0,(a0)            ;TRUE/FALSE
  10338. .not9
  10339.     cmp.w    #10,gg_GadgetID(a2)
  10340.     bne.b    .not10
  10341.     lea    pou+3,a0
  10342.     bchg    #0,(a0)            ;TRUE/FALSE
  10343. .not10
  10344.     cmp.w    #11,gg_GadgetID(a2)
  10345.     bne.b    .not11
  10346.     lea    poi+3,a0
  10347.     bchg    #0,(a0)            ;TRUE/FALSE
  10348. .not11
  10349.     bra.w    .nextmsg
  10350. .notup
  10351.     cmp.l    #IDCMP_GADGETDOWN,d2
  10352.     bne.b    .notdown
  10353.     tst.w    gg_GadgetID(a2)
  10354.     bne.b    .not0
  10355.     lea    pol,a0
  10356.     move.l    d3,(a0)
  10357.  
  10358.     move.l    .titlegadget(pc),a0
  10359.     move.l    .pwindowptr(pc),a1
  10360.     suba.l    a2,a2
  10361.     BASE    intui
  10362.     cmp.l    #2,d3
  10363.     beq.s    .a
  10364.     call    OffGadget
  10365.     bra.S    .b
  10366. .a
  10367.     call    OnGadget
  10368. .b
  10369.     bra.w    .nextmsg
  10370. .not0
  10371.     cmp.w    #1,gg_GadgetID(a2)
  10372.     bne.b    .not1
  10373.     lea    pom,a0
  10374.     move.l    d3,(a0)
  10375.     bra.w    .nextmsg
  10376. .not1
  10377.     cmp.w    #2,gg_GadgetID(a2)
  10378.     bne.b    .not2
  10379.     lea    por,a0
  10380.     move.l    d3,(a0)
  10381. .not2
  10382.     bra.w    .nextmsg
  10383. .notdown
  10384.     cmp.l    #IDCMP_REFRESHWINDOW,d2
  10385.     bne.w    .nextmsg
  10386.     BASE    gt
  10387.     move.l    .pwindowptr(pc),a0
  10388.     call    GT_BeginRefresh
  10389.     move.l    .pwindowptr(pc),a0
  10390.     moveq    #TRUE,d0
  10391.     call    GT_EndRefresh
  10392.     bra.w    .nextmsg
  10393. .error
  10394.     BASE    exec
  10395.     call    Forbid
  10396.     BASE    gt
  10397. .nextmsg1
  10398. .nextmsg2
  10399.     move.l    .pwindowptr(pc),a0
  10400.     move.l    wd_UserPort(a0),a0
  10401.     call    GT_GetIMsg
  10402.     tst.l    d0
  10403.     beq.b    .nullmsg2
  10404.     move.l    d0,a1
  10405.     call    GT_ReplyIMsg
  10406.     bra.b    .nextmsg2
  10407. .nullmsg2
  10408.     BASE    exec
  10409.     call    Permit
  10410.  
  10411.     BASE    intui
  10412.     move.l    .pwindowptr(pc),d0
  10413.     beq.b    .nowindow
  10414.     move.l    d0,a0
  10415.     call    CloseWindow
  10416. .nowindow
  10417.     lea    .pwindowptr(pc),a0
  10418.     clr.l    (a0)
  10419.  
  10420.     BASE    gt
  10421.     lea    .pgadgetptr(pc),a2
  10422.     move.l    (a2),a0
  10423.     call    FreeGadgets
  10424.     clr.l    (a2)
  10425.  
  10426.     moveq    #0,d0
  10427.     rts
  10428. .fixset
  10429.     moveq    #0,d0
  10430.     lea    mpheader+1,a0
  10431.     move.b    pol+3,(a0)+
  10432.     beq.b    .olle1
  10433.     addq    #1,d0
  10434. .olle1
  10435.     move.b    pom+3,(a0)+
  10436.     beq.b    .olle2
  10437.     addq.b    #2,-1(a0)
  10438.     addq    #1,d0
  10439. .olle2
  10440.     move.b    por+3,(a0)+
  10441.     beq.b    .olle3
  10442.     addq.b    #2,-1(a0)
  10443.     addq    #1,d0
  10444. .olle3
  10445.     lea    mpinfo,a0
  10446.     move.b    #1,(a0)
  10447.     tst.w    d0
  10448.     bne.b    .olle4
  10449.     clr.b    (a0)
  10450. .olle4
  10451.     lea    mpww,a0
  10452.     move.b    pow+3,(a0)
  10453.     lea    pob,a0
  10454.     move.l    (a0)+,d1
  10455.     move.l    (a0)+,d0
  10456.     lsl.w    #1,d0
  10457.     or.w    d0,d1
  10458.     move.l    (a0)+,d0
  10459.     lsl.w    #2,d0
  10460.     or.w    d0,d1
  10461.     lea    mpheader,a0
  10462.     move.b    d1,(a0)
  10463.     move.l    .titlegadget(pc),a0
  10464.     move.l    gg_SpecialInfo(a0),a0
  10465.     move.l    si_Buffer(a0),a0
  10466.     lea    mptitle,a1
  10467.     moveq    #29+1,d0        ;nollan oxå!
  10468. .copytitle
  10469.     move.b    (a0)+,(a1)+
  10470.     dbeq    d0,.copytitle
  10471.     move.l    .tabgadget(pc),a0
  10472.     move.l    gg_SpecialInfo(a0),a0
  10473.     move.l    si_LongInt(a0),d0
  10474.     lea    mptab,a0
  10475.     cmp.l    #16,d0
  10476.     bls.b    .tsok
  10477.     moveq    #16,d0
  10478. .tsok
  10479.     move.l    d0,(a0)
  10480.     moveq    #0,d0
  10481.     rts
  10482. .resset
  10483.     lea    .l2(pc),a0
  10484.     lea    pol,a1
  10485.     move.l    (a0)+,(a1)+
  10486.     move.l    (a0)+,(a1)+
  10487.     move.l    (a0)+,(a1)+
  10488.     move.l    (a0)+,(a1)+
  10489.     move.l    (a0)+,(a1)+
  10490.     move.l    (a0)+,(a1)+
  10491.     move.l    (a0)+,(a1)+
  10492.     moveq    #0,d0
  10493.     rts
  10494. .pnewgadget    blk.b    gng_SIZEOF,0
  10495. .pwindowptr    dc.l    0
  10496. .pwindowtags
  10497.     dc.l    WA_Left
  10498. .pwinx    dc.l    50
  10499.     dc.l    WA_Top
  10500. .pwiny    dc.l    25
  10501.     dc.l    WA_Width,428
  10502.     dc.l    WA_Height,142
  10503.     dc.l    WA_CustomScreen
  10504. .pwindowonscreen
  10505.     dc.l    0
  10506.     dc.l    WA_SmartRefresh,TRUE
  10507.     dc.l    WA_Activate,TRUE
  10508.     dc.l    WA_IDCMP,IDCMP_REFRESHWINDOW!MXIDCMP!BUTTONIDCMP!CHECKBOXIDCMP!INTEGERIDCMP!STRINGIDCMP
  10509.     dc.l    TAG_DONE
  10510.  
  10511. .lefttags
  10512.     dc.l    GTMX_Labels,.leftlabels
  10513.     dc.l    GTMX_Spacing,2
  10514.     dc.l    GTMX_Active
  10515. .leftactive
  10516.     dc.l    0
  10517.     dc.l    TAG_DONE
  10518. .leftlabels
  10519.     dc.l    .none
  10520.     dc.l    .filename
  10521.     dc.l    .title
  10522.     dc.l    0
  10523. .midtags
  10524.     dc.l    GTMX_Labels,.midlabels
  10525.     dc.l    GTMX_Spacing,2
  10526.     dc.l    GTMX_Active
  10527. .midactive
  10528.     dc.l    0
  10529.     dc.l    TAG_DONE
  10530. .midlabels
  10531.     dc.l    .none
  10532.     dc.l    .date
  10533.     dc.l    .pagenum
  10534.     dc.l    0
  10535. .righttags
  10536.     dc.l    GTMX_Labels,.rightlabels
  10537.     dc.l    GTMX_Spacing,2
  10538.     dc.l    GTMX_Active
  10539. .rightactive
  10540.     dc.l    0
  10541.     dc.l    TAG_DONE
  10542. .rightlabels
  10543.     dc.l    .none
  10544.     dc.l    .date
  10545.     dc.l    .pagenum
  10546.     dc.l    0
  10547. .wwtags
  10548.     dc.l    GTCB_Checked
  10549. .wwon
  10550.     dc.l    0
  10551.     dc.l    TAG_DONE
  10552. .titletags
  10553.     dc.l    GTST_String,mptitle
  10554.     dc.l    GTST_MaxChars,30
  10555.     dc.l    GA_TabCycle,FALSE
  10556.     dc.l    TAG_DONE
  10557. .tabtags
  10558.     dc.l    GTIN_Number
  10559. .tabsize
  10560.     dc.l    8
  10561.     dc.l    GTIN_MaxChars,2
  10562.     dc.l    GA_TabCycle,TRUE
  10563.     dc.l    TAG_DONE
  10564.  
  10565. .boldtags
  10566.     dc.l    GTCB_Checked
  10567. .boldon
  10568.     dc.l    0
  10569.     dc.l    TAG_DONE
  10570. .italtags
  10571.     dc.l    GTCB_Checked
  10572. .italon
  10573.     dc.l    0
  10574.     dc.l    TAG_DONE
  10575. .undertags
  10576.     dc.l    GTCB_Checked
  10577. .underon
  10578.     dc.l    0
  10579.     dc.l    TAG_DONE
  10580.  
  10581. .pgadgetptr    dc.l    0
  10582. .leftgadget    dc.l    0
  10583. .midgadget    dc.l    0
  10584. .rightgadget    dc.l    0
  10585. .wwgadget    dc.l    0
  10586. .printgadget    dc.l    0
  10587. .usegadget    dc.l    0
  10588. .cancelgadget    dc.l    0
  10589. .titlegadget    dc.l    0
  10590. .tabgadget    dc.l    0
  10591. .boldgadget    dc.l    0
  10592. .italgadget    dc.l    0
  10593. .undergadget    dc.l    0
  10594.  
  10595. .none    dc.b    "Nothing",0
  10596. .filename dc.b    "Filename",0
  10597. .title    dc.b    "Title",0
  10598. .date    dc.b    "Date",0
  10599. .pagenum dc.b    "Page #",0
  10600. .ww    dc.b    "Wrap words",0
  10601. .print    dc.b    "Print",0
  10602. .use    dc.b    "Use",0
  10603. .cancel    dc.b    "Cancel",0
  10604. .tab    dc.b    "Tab size",0
  10605. .bold    dc.b    "Bold",0
  10606. .ital    dc.b    "Italic",0
  10607. .under    dc.b    "Underlined",0
  10608.     even
  10609.  
  10610. .l2    dc.l    0
  10611. .m2    dc.l    0
  10612. .r2    dc.l    0
  10613. .w2    dc.l    0
  10614. .b2    dc.l    TRUE
  10615. .i2    dc.l    FALSE
  10616. .u2    dc.l    TRUE
  10617.  
  10618. .windowtext
  10619.     dc.b    2,0,RP_JAM2,0
  10620.     dc.w    162,5
  10621.     dc.l    NULL
  10622.     dc.l    .text1
  10623.     dc.l    .it2
  10624. .it2
  10625.     dc.b    1,0,RP_JAM2,0
  10626.     dc.w    20,20
  10627.     dc.l    NULL
  10628.     dc.l    .text2
  10629.     dc.l    .it3
  10630. .it3
  10631.     dc.b    1,0,RP_JAM2,0
  10632.     dc.w    170,20
  10633.     dc.l    NULL
  10634.     dc.l    .text3
  10635.     dc.l    .it4
  10636. .it4
  10637.     dc.b    1,0,RP_JAM2,0
  10638.     dc.w    320,20
  10639.     dc.l    NULL
  10640.     dc.l    .text4
  10641.     dc.l    .it5
  10642. .it5
  10643.     dc.b    1,0,RP_JAM2,0
  10644.     dc.w    20,65
  10645.     dc.l    NULL
  10646.     dc.l    .text5
  10647.     dc.l    NULL
  10648.  
  10649. .text1    dc.b    "Print options",0
  10650. .text2    dc.b    "Left field",0
  10651. .text3    dc.b    "Middle field",0
  10652. .text4    dc.b    "Right field",0
  10653. .text5    dc.b    "Header style",0
  10654.  
  10655.     even
  10656.  
  10657.     incdir    ""
  10658.     include    Projekt:Textread/CASE/Textread.s
  10659.